Highcharts Error #19的解决方法

1 篇文章 0 订阅
1 篇文章 0 订阅

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值