Closed anttirautanen closed 9 years ago
Hi there
Thanks for the bug. I was able to reproduce. We need to look into this and it's most likely due to an endless loop in the Chartist.getBounds
function.
I also encountered this error. Would appreciate a fix. <3
+1 on this bug. Great library by the way, thank you
The issues seems to be in the Pollard Rho algorithm (Chartist.rho). Seems to work great if I add this snippet of code:
Chartist.rho = function(num) {
if (num == 1) {
return 1;
}
But that is probably not a legit fix.
On line 518 in chartist.js
do {
x1 = f(x1) % num;
x2 = f(f(x2)) % num;
divisor = gcd(Math.abs(x1 - x2), num);
console.log(divisor) // This will always return 1 and thus endlessly loop.
} while (divisor === 1);
Maybe you can try to find why the condition of only having data of 0 and 1 causes the issue? Ill look into it this weekend otherwise and plan a 0.8.1 release. Id also appreciate more investigation and a PR if anyone finds the time.
@antonigiske Actually after looking at the problem, your proposed fix is absolutely fine. Chartist.rho should return 1 immediately if called with 1.
I've added the fix to develop.
If a chart gets a series of only 1s or 0s, the whole page hangs and no charts are drawn. The following code hangs at least on Chrome 42.0.2311.135 and Firefox 35.0.1.
These series would hang too:
If you remove the option
onlyInteger: true
then there are no problems.