question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Axis won't use decimal point values for scaling

See original GitHub issue

Hey 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)

  1. 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nagixcommented, Aug 22, 2018

This is resolved by #4841. Set ticks.precision to 1.

0reactions
nagixcommented, Oct 24, 2018

This was not fixed in #4841 because ticks.precision is effective only if stepSize is not specified. I created a new PR #5786.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found