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

Crash when plotting with ticks that are almost zero #6420

Closed
veggiesaurus opened this issue Jul 31, 2019 · 0 comments · Fixed by #6423
Closed

Crash when plotting with ticks that are almost zero #6420

veggiesaurus opened this issue Jul 31, 2019 · 0 comments · Fixed by #6423

Comments

@veggiesaurus
Copy link
Contributor

veggiesaurus commented Jul 31, 2019

Expected Behavior

Charts should plot successfully, even when ticks are small

Current Behavior

Currently, under certain circumstances, the tick array generated by Chart.js can include very small numbers instead of zero, due to rounding error. For example, the tick array generated could be [-0.00002, -0.00001, -3.4e-21, 0.000009999].
In this case, the linear formatter will crash, because the argument it passes to toExponential is less than zero.

Possible Solution

A min/max clamp between 0 and 20 is needed for the argument to toExponential, similar to the approach used for toFixed a few lines below.

Steps to Reproduce (for bugs)

Can't seen to coerce the ticks to misbehave in a specific codepen, but it is affecting our software here: carta-frontend/#433

Context

Environment

  • Chart.js version: 2.80
  • Browser name and version: Chrome 75
@veggiesaurus veggiesaurus changed the title Crash when plotting with ticks that are _almost_ zero Crash when plotting with ticks that are almost zero Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant