javascript Highcharts 数字格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15031749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highcharts numberformat
提问by Joaquimn
name: 'Name',
data: [1.57,1.57,1.51,1.44,1.44,1.37,1.35,1.33,1.33,1.27,1.27,1.24,1.22,0.98],
color: '#A61E22',
dataLabels: {
enabled: true,
rotation: -90,
color: '#000000',
align: 'right',
x: 4,
y: -35,
style: {
fontSize: '10px',
fontFamily: 'Verdana, sans-serif'
}
}
}]
I have the following code. Is there any way to use the function number format throughout the series? I need to replace the dots by commas. I need the number format like this:
我有以下代码。有没有办法在整个系列中使用函数编号格式?我需要用逗号替换点。我需要这样的数字格式:
number_format (series_values, 2, ',', '.');
回答by Ricardo Alvaro Lohmann
Highcharts.setOptions({
lang: {
decimalPoint: ',',
thousandsSep: '.'
},
tooltip: {
yDecimals: 2 // If you want to add 2 decimals
}
});
Reference
参考
回答by Yoann Augen
Not sure yDecimals is working now. Seem to be tooltip.valueDecimals now.
不确定 yDecimals 现在是否有效。现在似乎是 tooltip.valueDecimals。
Here what I'm using :
这是我正在使用的:
Highcharts.setOptions({
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
});
And in the chart :
在图表中:
tooltip: {
valueDecimals: 2
},
回答by Sebastian Bochan
You can also use formatter for tooltip / labels
您还可以将格式化程序用于工具提示/标签
http://api.highcharts.com/highcharts#tooltip.formatterhttp://api.highcharts.com/highcharts#xAxis.labels.formatter
http://api.highcharts.com/highcharts#tooltip.formatter http://api.highcharts.com/highcharts#xAxis.labels.formatter
and then use numberFormat: https://api.highcharts.com/class-reference/Highcharts#.numberFormat
然后使用 numberFormat:https://api.highcharts.com/class-reference/Highcharts#.numberFormat