在web端使用highcharts绘线性图的时候,遇到了Highcharts Error #19
到网站上一搜索,
Highcharts Error #19
Too many ticks
This error happens when you try to apply too many ticks to an axis, specifically when you add more ticks than the axis pixel length. In practice, it doesn't make sense to add ticks so densely that they can't be distinguished from each other. One cause of
the error may be that you set a tickInterval that is too small for the data value range. In general, tickPixelInterval is a better option, as it will handle this automatically. Another
case is if you try to set categories on a datetime axis, which will result in Highcharts trying to add one tick on every millisecond since 1970.
总体意思就是说,分割太细,导致无法绘图。
原来出错的代码是这样的
rel.tick = parseInt((rel.max - rel.min) / 6);
如此代码,导致你的数据里面如果出现了小数,而且整数部分一致的话,tick就会为0,导致分割单位为0,将产生无效分割数。
故修改成
//rel.tick = parseInt((rel.max - rel.min) / 6); rel.tick = parseFloat(((rel.max - rel.min) / 6).toFixed(2));就可以完美解决问题了。

本文详细解析了在Web端使用Highcharts绘制线性图时遇到的HighchartsError#19问题,即‘Too many ticks’错误。该错误发生于尝试在一个轴上应用过多的刻度时。文章提供了导致此问题的代码片段,并给出了修正方法,通过调整tick间隔来避免刻度过密,确保图表能够正常绘制。
4491

被折叠的 条评论
为什么被折叠?



