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

[BUG] Chart disappears when having y-values that are very close to each other #5932

Closed
janpaul123 opened this issue Dec 21, 2018 · 3 comments

Comments

@janpaul123
Copy link

screen shot 2018-12-21 at 11 56 31 am

Expected Behavior

When having a scatter plot with points of which the y-values are extremely close to each other, the y-axis should at least show something, and points should not disappear entirely. Maybe there is a limit to which the y-axis can zoom or something, but it should not go away.

Current Behavior

When having a scatter plot with points of which the y-values are extremely close to each other, the y-axis disappears entirely and it looks as if there is no data at all.

Steps to Reproduce

  1. Go to http://jsfiddle.net/eg3894u5/2/
  2. Notice that the y-axis is missing, and that no points are being shown, even though there are two points in the data set.
  3. If you uncomment the one line that adds one point, notice how everything works fine.

Context

This was noticed by a user of an internal tool who was confused that no data was shown at all in the chart in certain circumstances, even when they could see through other means that there was in fact data available.

Environment

  • Chart.js version: 2.7.3
  • Browser name and version: Google Chrome 71.0.3578.98

Thank you for a great library! Let me know if you need any more details. Happy to help fixing this, but don't have too much context on internals of axis scaling.

@kurkle
Copy link
Member

kurkle commented Dec 26, 2018

This has to do with floating point inaccuracy, SO: Why Are Floating Point Numbers Inaccurate?

As a workaround, there are multiple options that can be used to affect this: tick-configuration

http://jsfiddle.net/nxgmr4ah/

@janpaul123
Copy link
Author

janpaul123 commented Dec 26, 2018

Ah, that seems like a good workaround, thanks! I still think it's a bug that with default configuration it basically appears to crash. Maybe we should just have precision default to the minimum precision that Javascript/Chart.js can handle?

@janpaul123
Copy link
Author

Amazing!! Thank you for fixing this! 🙌

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