Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

negative values not handled #763

Closed
wirlygig opened this issue Nov 14, 2014 · 1 comment
Closed

negative values not handled #763

wirlygig opened this issue Nov 14, 2014 · 1 comment

Comments

@wirlygig
Copy link

the charts do not handle negatives. when a negative value is entered it shows off grid. Is it possible to get the bar chart to also handle a negative value? Even when setting the starting value as a negative it does not render correct. The negative values should start at 0 and go down not start at -200 and go up. Now this is with scaleBeginAtZero: false, but with scaleBeginAtZero: true the negatives run down below the chart and cannot be seen.

Example:

var randomScalingFactor = function () { return Math.round(Math.random() * 100) };
var barChartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
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: [-129, 52, 7, 42, 16, 0, 3]
},
{
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: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
},
{
fillColor: "rgba(240,73,73,0.5)",
strokeColor: "rgba(240,73,73,0.8)",
highlightFill: "rgba(240,73,73,0.75)",
highlightStroke: "rgba(240,73,73,1)",
data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
}
]
};
window.onload = function () {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).StackedBar(barChartData, {
responsive: true, scaleBeginAtZero: false

});
};

@etimberg
Copy link
Member

Closing as duplicate of #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants