I have a d3 scale. The tick values are fixed at [0, -0.5, -1]. With the tick format set to ".2s" the value -0.5 is displayed as -500m. Without the tick format set, the value is displayed correctly.
Formatting function works as properly in your case. format(".2s")
it means "SI-prefix with two significant digits" - from docs. There is awesome demo-page when you can choose formatting function for you - http://bl.ocks.org/zanarmstrong/05c1e95bf7aa16c4768e
According to the documentation at https://github.com/d3/d3-format the format you've chosen is defined as:
d3.format(".2s")(42e6); // SI-prefix with two significant digits, "42M"
Wikipedia states the preference of International System of Units:
Prefixes corresponding to an integer power of one thousand are generally preferred. Hence 100 m is preferred over 1 hm (hectometre) or 10 dam (decametres)...
Thus, .5 in the format you've chosen comes to 500m which is preferred display for the format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With