Chart.js
Chart.js copied to clipboard
Bar chart doesn't display negative values.
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
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.
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/