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

Extend labelsKMB for milli, micro, nano #994

Closed
lab-w opened this issue Apr 21, 2020 · 2 comments · Fixed by #1022
Closed

Extend labelsKMB for milli, micro, nano #994

lab-w opened this issue Apr 21, 2020 · 2 comments · Fixed by #1022

Comments

@lab-w
Copy link

lab-w commented Apr 21, 2020

The option "labelsKMB" in dygraphs 2.1.0 allows automatic labeling with kilo, mega and giga prefixes.
It would be great if that could be extended to milli (m), micro (µ) and nano (n).

Or is there maybe another option that allows this already?

By the way: the right unit prefix for kilo would be a lower case k (https://en.wikipedia.org/wiki/Unit_prefix).

@mirabilos
Copy link
Collaborator

Yes, please! 0.1m is just wrong as in the example, 1000 is k not K, 1024 may be K (but never k) but preferred is Ki, 1048576 ought to be Mi, etc.

So, ideally, you’d have these:

y Yocto‑ (10⁻²⁴) (1000⁻⁸)
z Zepto‑ (10⁻²¹) (1000⁻⁷)
a Atto‑  (10⁻¹⁸) (1000⁻⁶)
f Femto‑ (10⁻¹⁵) (1000⁻⁵)
p Piko‑  (10⁻¹²) (1000⁻⁴)
n Nano‑  (10⁻⁹)  (1000⁻³)
µ Mikro‑ (10⁻⁶)  (1000⁻²)
m Milli‑ (10⁻³)  (1000⁻¹)

k Kilo‑  (10³)   (1000¹)
M Mega‑  (10⁶)   (1000²)
G Giga‑  (10⁹)   (1000³)
T Tera‑  (10¹²)  (1000⁴)
P Peta‑  (10¹⁵)  (1000⁵)
E Exa‑   (10¹⁸)  (1000⁶)
Z Zetta‑ (10²¹)  (1000⁷)
Y Yotta‑ (10²⁴)  (1000⁸)

Ki Kibi‑ (2¹⁰)   (1024¹)
Mi Mebi‑ (2²⁰)   (1024²)
Gi Gibi‑ (2³⁰)   (1024³)
Ti Tebi‑ (2⁴⁰)   (1024⁴)
Pi Pebi‑ (2⁵⁰)   (1024⁵)
Ei Exbi‑ (2⁶⁰)   (1024⁶)
Zi Zebi‑ (2⁷⁰)   (1024⁷)
Yi Yobi‑ (2⁸⁰)   (1024⁸)

But a “legacy” mode for 2ˣ-based units in which they use K/M/G/T/P/E/Z/Y would be acceptable as option, and this is the only place where an upper-case K is okay.

The demo also shows Q, whatever that is supposed to be, it’s not a præfix.

mirabilos added a commit to mirabilos/dygraphs that referenced this issue Sep 7, 2022
@mirabilos
Copy link
Collaborator

mirabilos commented Sep 7, 2022

I think mirabilos/dygraphs@6d28d02...mirabilos:dygraphs:pr-units should do it, but I need to learn how to build and unit-test this first, then adapt the tests. (I’m an experienced developer, but more on the assembly/C level and playing with js for this library here.)

I also found that labelsKMG2 does weird things for “small” values (like milli), which danvk already noted, but in addition probably 10-based instead of 2-based. This is fixed.

I made using both options together activate the “legacy/deprecated” mode with K/M/G… for 1024-based and even using m/µ/n… there (the normal labelsKMG2 after this patch honours IEC 60027-2 and therefore has no “small” præficēs).

Comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants