отображать K и M в угловой диаграмме nvd3 Yaxis

0

Не могли бы вы помочь мне изменить отображение в моем угловом nvd3 yAxis2. На самом деле я пытаюсь изменить отображение, например, с 9000 до 9K. Я знаю, что это может быть сделано с помощью d3.formatPrefix(".1", 1e6) но я не смог это сделать. вот плункер для этого

Теги:
d3.js
nvd3.js
angular-nvd3

1 ответ

1
Лучший ответ

вам не нужно использовать d3.formatPrefix(". 1", 1e6). вы уже используете правильный формат d3.format(',.2f')(d) просто вам нужно изменить f на s как указано в 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.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню