try to fix some bugs in ecStat.js. details below …
Sometimes precision will become negavite value (I don't know why), set it to -precision or 0 (I don't know why, but my code works for me) if this happens.
有的时候precision这个值会变成负数,导致出错,根据其他issue里的建议,我修改了部分precision的值,有的时候设成了-precision,有时设成了0,总之现在我这里不再出这个报错了。
Doing rangeArray[i - 1] + step is not right, rangeArray is an array of floats while step is a string, which makes 20 + '0.1' become '200.1', change it to (rangeArray[i - 1] + parseFloat(step));
在计算bins的x0和x1的时候,计算到最后一个元素需要计算rangeArray[i - 1] + step,这时前项是float而后项是string,导致计算结果错误。
+((bin.x0 + bin.x1) / 2).toFixed(precision) will produce depulicated value, try this in your console: ((1.4+1.5)/2).toFixed(1) and ((1.3+1.4)/2).toFixed(1) will both produce 1.4
计算bins的最后,toFixed导致了部分相邻项目会重叠。
var ret = +((stop >= start ? step1 : -step1).toFixed(precision)); sometimes ret will be 0 (I don't know and why), but when this happens, just return 0.1
有时返回的step会变成0,不知道为什么,但是强行设置成了0.1可以避免出错。
https://github.com/ecomfe/echarts-stat/compare/master...liangaili:patch-1
try to fix some bugs in ecStat.js. details below …
Sometimes precision will become negavite value (I don't know why), set it to -precision or 0 (I don't know why, but my code works for me) if this happens. 有的时候precision这个值会变成负数,导致出错,根据其他issue里的建议,我修改了部分precision的值,有的时候设成了-precision,有时设成了0,总之现在我这里不再出这个报错了。
Doing rangeArray[i - 1] + step is not right, rangeArray is an array of floats while step is a string, which makes 20 + '0.1' become '200.1', change it to (rangeArray[i - 1] + parseFloat(step)); 在计算bins的x0和x1的时候,计算到最后一个元素需要计算rangeArray[i - 1] + step,这时前项是float而后项是string,导致计算结果错误。
+((bin.x0 + bin.x1) / 2).toFixed(precision) will produce depulicated value, try this in your console: ((1.4+1.5)/2).toFixed(1) and ((1.3+1.4)/2).toFixed(1) will both produce 1.4 计算bins的最后,toFixed导致了部分相邻项目会重叠。
var ret = +((stop >= start ? step1 : -step1).toFixed(precision)); sometimes ret will be 0 (I don't know and why), but when this happens, just return 0.1 有时返回的step会变成0,不知道为什么,但是强行设置成了0.1可以避免出错。