我是 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]
}]
});
最佳答案
这似乎是 Highcharts.numberFormat
函数的限制 - 对于非常小的数字,无法更改带有 e 的表示法。
您可以使用toFixed()
代替:
formatter: function () {
return this.y.toFixed(7);
}
关于javascript - 在 HighCharts 中设置超过 6 位小数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49683246/