Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Bar chart doesn't display negative values.

Open Samuel1989 opened this issue 11 years ago • 2 comments

I have looked at the pre-existing issues which all seem to imply that this was fixed in 1.x... However, when trying the following:

var data = {
    labels: ["January", "February", "March", "April", "May", "June", "July", "August"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "rgba(220,220,220,0.5)",
            strokeColor: "rgba(220,220,220,0.8)",
            highlightFill: "rgba(220,220,220,0.75)",
            highlightStroke: "rgba(220,220,220,1)",
            data: [65, 59, 80, 81, 56, 55, 40, -30]
        },
        {
            label: "My Second dataset",
            fillColor: "rgba(151,187,205,0.5)",
            strokeColor: "rgba(151,187,205,0.8)",
            highlightFill: "rgba(151,187,205,0.75)",
            highlightStroke: "rgba(151,187,205,1)",
            data: [28, 48, 40, 19, 86, 27, 90, -42]
        }
    ]
};

var options = {
    scaleBeginAtZero: false,
    responsive: true
};

var ctx = document.getElementById("myChart").getContext("2d");
var myBarChart = new Chart(ctx).Bar(data, options);

All bars start from -100... Am I missing an option?

Thank you, Sam

Samuel1989 avatar Nov 10 '15 16:11 Samuel1989

Are you able to reproduce using the Release 1.1 version?

https://github.com/nnnick/Chart.js/tree/release/1.1

There is a zip button on the right to download.

fulldecent avatar Nov 16 '15 23:11 fulldecent

Alternative solution is to move to v2. There are no issues with negative values in v2. The documentation for v2 is hosted at http://nnnick.github.io/Chart.js/docs-v2/

etimberg avatar Dec 26 '15 17:12 etimberg