gpt4 book ai didi

javascript - 在 HighCharts 中设置超过 6 位小数?

转载 作者:行者123 更新时间:2023-12-03 02:08:33 26 4
gpt4 key购买 nike

我是 HighStocks API 的新手,我正在尝试为小数设置 8 位小数(例如“0.00000001”)。

我已经测试了多种格式化方法,但我无法使用下面的这些值来格式化超过 6 个小数点的大小写。

我不知道这是 JS 的错误还是 HighCharts 的限制,我只是想让这个工作正常。

谢谢。

JSFiddle Link

$('#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);
}

现场演示:http://jsfiddle.net/BlackLabel/0cmLcrLp/

关于javascript - 在 HighCharts 中设置超过 6 位小数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49683246/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com