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

beginAtZero ignored in line-chart #1579

Closed
stephanarts opened this issue Oct 27, 2015 · 8 comments
Closed

beginAtZero ignored in line-chart #1579

stephanarts opened this issue Oct 27, 2015 · 8 comments

Comments

@stephanarts
Copy link

I want to use Chart.js to draw a time-line graph of values that can not have a negative value. - Think about CPU-load (floating-point value between 0.0 and a lot), network-throughput (bytes/s).

The timescale graph in Chart.js 2.0 appears to be a good fit, but it looks weird if the base-line is drawn at the center of the graph. (which happens if you draw a lot of values between 0.08 and 0.2).

I get the impression that beginAtZero is ignored in the line-chart.

@etimberg etimberg added the v2.x label Oct 27, 2015
@etimberg
Copy link
Member

@stephanarts beginAtZero should work, though the config has changed since V1. Here's a JSBin with the beginAtZero option. You can try changing it and seeing the effect.

@stephanarts
Copy link
Author

@etimberg I see what you mean, I was aware of the config-change and it does work. - sometimes.
It appears to be related to the x or y values assigned to the dataset.

If I assign the values hard-coded as strings in my js file, it works. If I retrieve them as a JSON object from an AJAX call it doesn't work. Let me check where the difference is coming from.

@stephanarts
Copy link
Author

I am clueless as to why it didn't work earlier... I must have done something terribly wrong.

@etimberg: thank you for confirming the location of the beginAtZero option in v2.0 :-)

@etimberg
Copy link
Member

@stephanarts glad its fixed. Let me know if you see it again and I'll give it a stress test.

@stephanarts
Copy link
Author

@etimberg I managed to reproduce it here: http://jsbin.com/dusesimiqa

@stephanarts stephanarts reopened this Oct 27, 2015
@etimberg
Copy link
Member

I see the issue. The relevant lines are: https://github.com/nnnick/Chart.js/blob/v2.0-dev/src/scales/scale.linear.js#L103-L106

@etimberg
Copy link
Member

@stephanarts a fix is in #1581

@stephanarts
Copy link
Author

Confirmed.

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

No branches or pull requests

2 participants