Black Lives Matter. Please consider donating to Black Girls Code today.

Formatting axis numbers - sigfigs without trailing zeroes

Trying to get the axis number formatting right in Plotly - all I want is to show 5 sigfigs while omitting trailing zeroes.

I’m having a hard time getting the effect described in this PR to work.

The syntax described in the PR isn’t in the documentation

Basically - is there a way to get rid of these trailing zeroes? I need to properly display arbitrarily small numbers (e.g. 0.00123), so simple truncation won’t work - I need a true sigfig method that omits trailing zeroes

format = ".5g"
f = d3.format(format);
f(0.00123)           ==> 0.0012300 ☹
f(40)                ==> 40.000  ☹
f(5180.159999999996) ==> 5180.2 🙂
f(999999)            ==> 1.0000e+6 🙂