在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));就可以完美解决问题了。