-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Unit: Add SI prefix for empty unit #79897
Conversation
I made a similar PR a while back, but it was closed due to inactivity (#78023). I'd love this functionality in my Grafana Cloud instances, so I'm creating a new one here with some improved branching/naming. Please let me know if there is anything lacking or if there is anything I can to better next time to have a PR merged. |
Dear reviewers @Clarity-89 @oshirohugo @eledobleefe Just wanted to check if there is a chance of a merge of this simple addition? If it's deemed too minor or uninteresting, please let me know. Thanks! |
@@ -45,6 +45,7 @@ export const getCategories = (): ValueFormatCategory[] => [ | |||
id: 'short', | |||
fn: scaledUnits(1000, ['', ' K', ' Mil', ' Bil', ' Tri', ' Quadr', ' Quint', ' Sext', ' Sept']), | |||
}, | |||
{ name: 'SI prefix', id: 'siprefix', fn: SIPrefix('') }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be identical to the "short" unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it would not. For example, 10000000000
would become 10 Bil
with the short
unit, while the proposed SI prefix unit would return 10 G
. Additionally, I don't think there's support for shortening values with exponent below 0. For example, 0.00001
would become the same with the short unit, while SI prefix
would return 10 u
.
Generally, I believe the SI prefix notation would be much more understandable in the engineering community, and perhaps also elsewhere. Especially since the convention for the number of zeros in billion, trillion etc varies across the globe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be a suffix if it's after the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting point, but I think the common term is prefix since the letter normally prefixes a unit. It's just that the unit in non-existent in this case. Maybe the name could be clarified to "Unitless SI prefix" or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe SI short
to present it as an alternative to the short
notation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raymalt yes, that is a better name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@torkelo ok, I pushed a new commit with an updated naming.
@raymalt could you please update this PR to the latest main? |
@Clarity-89 Not entirely sure what I just did was correct, could you please check? |
* Unit: Add SI prefix for empty unit * Units: Change name from SI prefix to SI short
* Unit: Add SI prefix for empty unit * Units: Change name from SI prefix to SI short
What is this feature?
It adds a new unit under the Misc category called SI prefix, which converts unit-less number labels on the y axis to the SI prefix notation.
Why do we need this feature?
Add the possibility to have SI prefix for empty units, for example convert 10000 to 10 k. This is useful when plotting multiple parameters with similar, but not identical units. One example is AC power quantities (active, reactive, apparent power), whose units are W, VAr and VA. The idea is to use the unit-less SI prefixing to get a clean y axis labeling.
Who is this feature for?
Any user who wants the shortened notation of numbers accomplished by creating SI prefix when a unit is not necessary or possible on the y axis.
Which issue(s) does this PR fix?:
Fixes #78022
Special notes for your reviewer:
Please check that: