d3-format
d3-format copied to clipboard
near-zero and near-100 rounding option
Right now using a simple percent format like:
const f = format('.1%')
Gives misleading results near 0
and 100
:
f(0.0001) // 0.0%
f(0.9999) // 100.0%
Even though these are technically correct from a rounding perspective, they lead to confusion for users because it reads as "absolute". Which is why it's common to instead refer these as:
<0.1%
>99.9%
It would be really nice if there was a flag for this style of percentage formatting.