-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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 is not drawn if values are smaller than 0.000001 #5653
Comments
Actually they can be smaller, as long as 1 of the values They can be even smaller, like https://codepen.io/hedva/pen/zLprMN Maybe with values this small, you can use 10^-5 as the axis label/info. So you could just numbers like 1, 2, 3, 6 in your chart |
Thanks for the reply. Is there any way to solve this problem? |
I had the same issue when plotting small numbers and as a work around I just multiplied all incoming data by a large number and then added callbacks to the yAxes and tooltips sections to divide by the same number so the correct value is shown on the axis and in the tooltips popup. I’ve attached a modified version of your test.txt file with the callbacks added |
The problem seems to be in the estimation of the Chart.js/src/scales/scale.linearbase.js Line 57 in 3830216
It uses the string length of the spacing between ticks. Unfortunately, for very small tick spacing the toString() method returns scientific notation which has string length smaller than expected and causes the precision calculation to be so small that all the ticks are 0.
|
The most versatile solution might be to switch to decimals for the ticks (http://mikemcl.github.io/decimal.js/). A quickfix for the problem could be
UPDATE: I can confirm, that the solution above works fine. You just need to install decimal.js: |
Expected Behavior
The chart should be drawn even if values are very small.
Current Behavior
chart is not drawn - axis are drawn but the line(s) doesn't
Steps to Reproduce (for bugs)
create a simple line chart with the following data:
data: [
Math.random()/1000000,
Math.random()/1000000,
Math.random()/1000000,
Math.random()/1000000,
Math.random()/1000000,
Math.random()/1000000,
Math.random()/1000000
],
Environment
change the attached file to .html to see example:
test.txt
The text was updated successfully, but these errors were encountered: