[英]Setting more than 6 decimal places in HighCharts?
我是HighStocks API的新手,我试图为低数字设置8个小数位(例如“ 0.00000001”)。
我已经测试了多种格式化方式,但是使用以下这些值,我无法格式化超过6种小数形式。
我不知道它是来自JS还是HighCharts limitaiton的错误,我只是想使其工作。
谢谢。
$('#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/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.