Round axis values with integersOnly
when Decimal format is 0
#170151
Labels
bug
Fixes for quality problems that affect the customer experience
Feature:ElasticCharts
Issues related to the elastic-charts library
Feature:Lens
impact:medium
Addressing this issue will have a medium level of impact on the quality/strength of our product.
Team:Visualizations
Visualization editors, elastic-charts and infrastructure
Kibana version:
latest on
main
Describe the bug:
Custom axis tick formatting with a decimal of
0
can cause tick labels to be placed inaccurately.Notice in the recording above the value at
13:40
is1.60
, but when setting the decimals value to0
, the value becomes2
and the axis tick label for1.6
becomes2
, with no change in the axis scale itself. This is wrong and this elastic/elastic-charts#1417 was never truly fixed, so I reopened it. It worth noting this case only happens when formatting at a small scale such that decimal tick values are shown.Really we need to format the value then somehow parse the formatted value to compare the value with the true value. Or maybe there is another way to take the lower/higher formatted value and remove the rest. Will continue this discussion in elastic/elastic-charts#1417.
Expected behavior:
Tick labels are always accurate to the numerical value they represent
1.6
should not be formatted to'2'
.Any additional context:
The solution here is to enable the
integersOnly
option on theAxis
, when the decimal value is set to0
, see example with the option here. I think this would cover most use cases but this would still occur for decimals set to1
or more just at a lower order of magnitude. Although this case is rare we could fully fixe this by telling charts the rounded decimal value which is why I opened elastic/elastic-charts#2220.This fix only applies to the Lens custom formatter and NOT to default formatter at the data view level. This is due to the use of
Numeral.js
, which does not permit a way of knowing the fractional digits to round to. This is would be a rare case to have an integer-only format at the data view level additionally, if it was a problem the user could just enable a Lens custom field formatter.Related to #170154
The text was updated successfully, but these errors were encountered: