我是HighStocks API的新手,我正在为低数字设置8位小数(例如“0.00000001”)。
我已经测试了很多格式化方法,但我不能使用下面这些值格式化超过6个十进制大小写。
我不知道它是来自JS还是HighCharts限制的错误,我只是想让这个工作。
感谢。
$('#container').highcharts({
chart: {
type: 'line'
},
title: {
text: 'Test'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Decimals'
}
},
plotOptions: {
line: {
dataLabels: {
enabled: true,
formatter: function () {
return Highcharts.numberFormat(this.y,8);
}
},
enableMouseTracking: false
}
},
series: [{
name: 'Test',
data: [0.00000020,0.00000020,0.00000020,0.00000020]
}]
});
答案 0 :(得分:1)
似乎是Highcharts.numberFormat
功能的限制 - 对于非常小的数字, e 的符号无法更改。
您可以改为使用toFixed()
:
formatter: function () {
return this.y.toFixed(7);
}