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

Epic: better number formatting strategy #35838

Open
leeoniya opened this issue Jun 16, 2021 · 3 comments
Open

Epic: better number formatting strategy #35838

leeoniya opened this issue Jun 16, 2021 · 3 comments
Labels
area/frontend type/epic Issue made of smaller issues

Comments

@leeoniya
Copy link
Contributor

there are quite a few issues - new and old - about surprising and undesirable behavior in different contexts.

still open:

#4252
#6193
#8621
#8957
#16253
#26857
#26909
#34951 (comment)

the last one is my recent attempt to simplify and speed up what currently exists, without changing the behavior. but it only does part of what's actually needed.

right now there are several layers that work together to parse, convert, round, re-parse, divide and concat a number to format it. instead, we should rely on Intl.NumberFormat to properly format numbers to a precision that takes locale and display context into account.

one example of context is "axis ticks", which can have a dynamic precision based on the min/max range of the axis, so that a default precision of 3 does not turn ticks of 1.105, 1.106, 1.107 into 1.10, 1.11, 1.11. a static number of decimal places will not work here either, since the panels can be zoomed a more precise ranges that exceed this as well.

the MM suffix is common in finance for millions in currency, but uncommon in many other contexts, where M and K are more prevalent. prior to joining Grafana i've never seen Mil used to represent "millions", but knew mil as a common unit of measure in engineering (.001 inch).

IMO, a lot of what exists can be simplified with some minor user-facing formatting changes, a couple extra options in the UI, and optimizing what exists internally.

@torkelo
Copy link
Member

torkelo commented Jun 16, 2021

yea agree a lot can be improved, not sure when M was changed to Mil, think a lot of users wanted SI units for eveything at some point, can't remember.

a couple extra options in the UI

This makes me a bit scared, better default behaviors are great. More options are scary as we have soo many already, they really need a strong reason to exist. But then again we have actually reduced the number of decimal options in v8, the old graph had separate decimal option axis ticks & legend :)

@aha-sage
Copy link

aha-sage commented Mar 2, 2022

@torkelo I saw what you answered at #36448 and this is happening when is set to auto as well...

For example:
image
The right y-axis is for a number of routes advertised.
It is on short unit and Decimals = 0 (to not use never 0.5 e.g.)

For this case I can't use softmax easily because it doesn't make sense for this kind of graph, since it keeps oscillating around numbers. If the panel is taller, the issue gets even worse.
image

Is there any plans on fixing it?

@ATarrio
Copy link

ATarrio commented Dec 14, 2023

Hi, I'm currently trying (without success) to apply locale formatting (adding commas to large numbers) for numbers I display on alerts using a template. Maybe whatever solution ends up being implemented would be even more awesome if it takes into account the possibility of localizing output in templates (say, using printf from golang.org/x/text/message along with golang.org/x/text/language like here: https://stackoverflow.com/questions/13020308/how-to-fmt-printf-an-integer-with-thousands-comma ?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend type/epic Issue made of smaller issues
Projects
None yet
Development

No branches or pull requests

4 participants