当数字太小时,Highcharts轴不会显示正确的值

时间:2015-03-20 09:21:01

标签: javascript highcharts

当系列接近零时,我刚刚发现了Highchart轴值的奇怪行为:

series: [{
  name: 'Tokyo',
  data: [0.0000000001,0.0000000002,0.0000000001,0.0000000002,0.0000000001,0.0000000002,0.0000000001,0.0000000002,0.0000000001,0.0000000002,0.0000000001,0.0000000002]
}]

请参阅:http://jsfiddle.net/u29mpdnk/

但是当系列与另一个数字相邻时,正在显示:

series: [{
  name: 'Tokyo',
  data: [12.0000000001,12.0000000002,12.0000000001,12.0000000002,12.0000000001,12.0000000002,12.0000000001,12.0000000002,12.0000000001,12.0000000002,12.0000000001,12.0000000002]
}]

请参阅:http://jsfiddle.net/m3zohat1/1/

看起来像个bug,不是吗?任何解决方法?

提前致谢

1 个答案:

答案 0 :(得分:0)

您可以使用yAxis label's formatter,然后使用Highcharts.dateFormat

labels:{
                tickInterval: 0.0000000001,
                formatter:function(){
                    return Highcharts.numberFormat(this.value, 11,'.');
                }
}

示例:http://jsfiddle.net/u29mpdnk/1/