d3-format icon indicating copy to clipboard operation
d3-format copied to clipboard

formatPrefix vs format handling of parentheses

Open laventnc opened this issue 2 years ago • 0 comments

When using 'formatPrefix' (which is preferred because it treats the precision as the number of digits past the decimal) it places the si prefix outside of the parentheses.

'format' handles this correctly, although it requires us to calculate the number of significant digits to the left of the decimal to arrive at similar functionality.

see:

const val = -694712
d3.formatPrefix("($.0~", val)(val)
// ($695)k
d3.format("($.3s")(val)
// ($695k)

laventnc avatar Oct 13 '23 17:10 laventnc