Axis won't use decimal point values for scaling
See original GitHub issueHey guys, I want to make the y axis ticks be in the step size of the max value (e.g. if the max value is 10, the ticks are 0, 2.5, 5, 7.5, 10). However it’s rounding up and I’m not sure how to prevent that. Option used:
Expected Behavior
Steps to have decimal values: [0, 2.5, 5, 7.5, 10]
Current Behavior
Steps get rounded up to : [0, 3, 5, 8, 10].
Steps to Reproduce (for bugs)
- Make sample chart with any data and use the following scale option:
scales: { yAxes: [{ ticks: { min: 0, max: 10, stepSize: 2.5, display: true, beginAtZero: true } }] }
Context
I want to be able to set the step size to any value I want and be able to scale properly. Currently when it automatically rounds up, it looks off and it’s not the result I want anyway.
Environment
- Chart.js version: 2.6
- Browser name and version: Nodejs 9
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to change the number of decimals in axis of Excel graphs
Your browser can't play this video. Learn more. Switch camera.
Read more >How to get Excel charts x-axis to scale with the data
Right click on the x-axis, select Format axis, go to the Number section, then select 'Number' in the drop down, select the number...
Read more >Skip decimal points on y-axis in chartJS - Stack Overflow
Unfortunately, this setting prevents skipping certain points when there is a lot of data. For example, when the values are from 0 to...
Read more >Y-axis displays decimals instead of integers - SAP Community
However, if the sum of values for the chart is very small (around -10 or 10) the y-axis suddenly switches to decimals. The...
Read more >Excel Chart, Axis Label decimal removal - Super User
1) Select the axis, right-click and choose "Format Axis" from teh pop-up menu. enter image description here. Under "number", Enter 0 (or the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is resolved by #4841. Set
ticks.precision
to 1.This was not fixed in #4841 because
ticks.precision
is effective only ifstepSize
is not specified. I created a new PR #5786.