-
Notifications
You must be signed in to change notification settings - Fork 170
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
Custom formatter for mesasures in Bits #649
Comments
I can't format that way with either version of numbro.js. Sadly, I don't think we can do anything about it - I don't see any other library that handles your case (which sounds simple!). |
Thanks for the feedback. I went searching upstream at the numbro.js repo. Would it be possible to utilize this feature (Byte symbol localization) for replacing B with b (yes it would def be hacky)? |
But wouldn't you need to multiply your input by 8? input: But you wan't to get Anyways, we had some plans for better formatters (#504) and I would like to leave this issue for future considerations. Maybe we will be able to handle this case. |
Great, thanks for taking this case into consideration. If calculation is needed to scale the values appropriately, this can be achieved by adding a custom measure with a corresponding formula. In our case the numbers that are shown in the UI are actually "in bits". Formatting them with the numbro bytes formatter does not change the actual value but only attach the suffix |
I think I'd reword this to be about "add support for unit prefixes". SI (multiples of 1000) would be a good start: for example for a unit of "bps" (cf. #634) it would be good to think in terms of "Mbps", "Gbps" etc, rather than "million bps", "billion bps" etc. For a unit of "bytes", then it gets a bit more complicated, as IEC prefixes (base 2) are more commonly used, so "MiB" = 1,048,576 bytes etc. |
For bytes, it seems like numbro.js offers that support with e.g. format: "0,0.00 b". Anything else is going to be more difficult I think, cf. BenjaminVanRyseghem/numbro#126 for a 2015-era task to add SI support to Numbro. |
This would show bytes units formatted using base 2 IEC/IEEE units (KiB/MiB/GiB etc.). Unfortunately, no support exists for generalized SI (or IEC) prefixes for other units, such as bps and pps. See allegro/turnilo#649 for the upstream feature request, which also links to the upstream Numbro.js feature request as well. Change-Id: I7ddc5ca83fcdb0b5a971effbea8cbbb49afb5094
Hello and thanks for this grandiose project!
We would be happy to have a formatter that writes "b" (lowercase B, signifying "bits") instead of "B" (uppercase B, signifying "bytes") following the relevant SI prefix (Ki/Mi/Gi).
Having bit based units displayed as B is actually quite irritating. At the moment we're calculating everything as Megabits and display that as a plain number but it's hard to read (739273 Megabits) and having SI prefixes for bits would be nicer.
Is this possible with plain numbro.js? The v1 docs only talk about Bytes.
The text was updated successfully, but these errors were encountered: