Specifying a number of significant digits?

Author: rickhuizingaCreated Jul 18, 2014Updated Oct 3, 2023
Labelsenhancement

First, this has been a very handy library.

I would like to limit the number of significant digits to 3 such that: $12600 -> $12.6k $342622 -> $343k $1242050 -> $1.24m

I haven't found a way to specify this style of formatting. It only allows me to specify the number of decimal points, which can be too much information.

For example, specifying 2 decimal points works for $1242050 -> $1.24m, but is not appropriate for $342622 -> $342.62k. Its just includes too much unnecessary information for displaying prices to users.

Is there a way to limit the total number of digits, rather than the number of decimal places? If not, could it be added?