Conversation
src/scales/scale.linearbase.js
Outdated
| } | ||
| var niceMin = Math.floor(dataRange.min / spacing) * spacing; | ||
| var niceMax = Math.ceil(dataRange.max / spacing) * spacing; | ||
| // If a precision is not speified, calculate factor based on spacing |
|
Maybe I didn't understand the issue / feature behind both options: I'm a bit worried about mixing both configs and have
I think we should support that case:
What about: |
|
When In that sense, it seems natual to me that |
|
Or, should the auto-generated tick interval be completely independent from the precision? Should In that case, there may be another confusion. eg. |
|
I understand, I thought that |
|
Thanks @benmccann, I have added a jsdoc and fixed a typo. |
simonbrunel
left a comment
There was a problem hiding this comment.
... but this may cause confusion. eg.
stepSize: 0.524, precision: 2results in 0, 0.52, 1.04, 1.56
I think the confusion comes from the fact that the precision applies to two concepts: the tick generation and the displayed format. Initially introduced to fix #4103, it's definitely not to control the displayed format, so you right.
Or, should the auto-generated tick interval be completely independent from the precision? Should precision be only applied to the generated tick values?
I think it's possible to override the display format with scale.ticks.callback but that's not really convenient.
Thanks @nagix
This PR adds support for decimal
stepSizefor linear scales. In the current code,stepSize>= 1, ticks will be rounded to integersstepSize< 1, ticks will have the appropriate decimal precisionstepSizeis not specified, the tick interval will be set to a 'nice' number, so there is no rounding issueIn this PR, the decimal precision is calculated based on
stepSizeif specified, or a generated 'nice' number orticks.precision(only ifstepSizeis not specified).Fixes #5392
Fixes #5579