2016-08-18 58 views
0

請你幫我改變我的角nvd3 yAxis2顯示。 事實上,我試圖將顯示從9000變爲9K。 我知道這可以使用d3.formatPrefix(".1", 1e6)來完成,但我無法做到。 這裏是一個plunker顯示K和M在角nvd3圖Yaxis

回答

1

你不需要使用d3.formatPrefix(「。1」,1e6)。 你已經在使用correctd格式d3.format(',.2f')(d)只是你需要改變fs作爲D3的GitHub網站中提到

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.