Skip to content
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

[Lens] For very small values XY axis can get many many zeros #143750

Open
dej611 opened this issue Oct 20, 2022 · 9 comments
Open

[Lens] For very small values XY axis can get many many zeros #143750

dej611 opened this issue Oct 20, 2022 · 9 comments
Labels
blocked bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@dej611
Copy link
Contributor

dej611 commented Oct 20, 2022

Describe the bug:

Divide a value by a very number in Lens (i.e. in formula with 1/BIG NUMBER HERE) to see the Y axis act in a weird way with the formatting.
I've discovered this while testing #143632 and later reproduced with static values.

weird_axis_bug_zeros

Expected behavior:

Avoid 0 duplicates - it's strange that the precision increases up to a point where it gets reduced to a simple 0
In general a better formatting strategy for this cases should be found.

@dej611 dej611 added bug Fixes for quality problems that affect the customer experience Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. labels Oct 20, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@flash1293
Copy link
Contributor

I'm not sure whether this is a Kibana or an elastic-charts bug - don't we have some logic in place to extend the axis in these situations to get different ticks @markov00 ? Maybe I'm misremembering...

@flash1293
Copy link
Contributor

marking as blocked for now until @markov00 had the chance to check it out :)

@markov00
Copy link
Member

markov00 commented Nov 8, 2022

This is caused by your formatting function used.
We don't call the axis formatted function with duplicate values, but we call it with specific subdivisions of the axis (in this case from 0 to 1/100000....)
In this case, it seems that the formatted is working fine up to 3/4 decimal points and then everything smaller is transformed to a no-decimal. Looks like a Numeraljs behavior:

numeral(0.01).format('0.[00]');  // === 0.01
numeral(0.001).format('0.[00]');  // === 0
numeral(0.0000001).format('0.[00]'); // NaN and in this case I think the code instead renders the number with a simple toString 1e-7

I don't think we should remove the duplicate zeros internally in charts, instead, we should take back ownership of the axis tick formatting and deliver the optimal representation every time. We should use the field formatters only in the tooltip, where the user requires the a particular precision. We could just provide a way to define prefix/postfix or the type of notation to use when formatting the axes values.

@flash1293
Copy link
Contributor

I don't think we should remove the duplicate zeros internally in charts, instead, we should take back ownership of the axis tick formatting and deliver the optimal representation every time. We should use the field formatters only in the tooltip, where the user requires the a particular precision. We could just provide a way to define prefix/postfix or the type of notation to use when formatting the axes values

Yeah, that's the bigger plan here. I think it makes sense to just block it on that for now.

@flash1293
Copy link
Contributor

Thanks for taking a look!

@markov00
Copy link
Member

markov00 commented Nov 8, 2022

I think it makes sense to just block it on that for now.

what do you mean? that we should the deduplication feature in elastic charts? I'm more on the idea to fix the field formatter logic in this case.

@markov00
Copy link
Member

markov00 commented Nov 8, 2022

because the problem is not just at the axis level, but also on the tooltip that is showing the wrongly formatted value as zero

Screenshot 2022-11-08 at 11 29 03

@flash1293
Copy link
Contributor

Sorry, didn't state that clearly. I meant rewriting the formatting so we don't get a blackbox number formatter based on numeral.js but a config object based on a standard that can be used more intelligently by all the places applying it: #102239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants