Med - 11 months ago 62

AngularJS Question

Would you please help me to change the display in my angular nvd3 yAxis2.

In fact I'm trying to change the display from for example from 9000 to 9K.

I know that may be it can be done using

`d3.formatPrefix(".1", 1e6)`

here is a plunker for that

Answer Source

you don't need to use d3.formatPrefix(".1", 1e6).
you are already using the correctd format `d3.format(',.2f')(d)`

just you need to change the `f`

with `s`

as mentioned in the d3 github site

```
The available type values are:
e - exponent notation.
f - fixed point notation.
g - either decimal or exponent notation, rounded to significant digits.
r - decimal notation, rounded to significant digits.
s - decimal notation with an SI prefix, rounded to significant digits.
% - multiply by 100, and then decimal notation with a percent sign.
p - multiply by 100, round to significant digits, and then decimal notation with a percent sign.
b - binary notation, rounded to integer.
o - octal notation, rounded to integer.
d - decimal notation, rounded to integer.
x - hexadecimal notation, using lower-case letters, rounded to integer.
X - hexadecimal notation, using upper-case letters, rounded to integer.
c - converts the integer to the corresponding unicode character before printing.
(none) - like g, but trim insignificant trailing zeros.
```