Skip to content

Commit

Permalink
Limit the number of iterations in scaleLinear.nice
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed May 20, 2020
1 parent 694ed8f commit 96b8f4b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/linear.js
Expand Up @@ -26,14 +26,14 @@ export function linearish(scale) {
let stop = d[i1];
let prestep;
let step;
let maxIter = 10;

if (stop < start) {
step = start, start = stop, stop = step;
step = i0, i0 = i1, i1 = step;
}

// eslint-disable-next-line no-constant-condition
while (true) {
while (maxIter-- > 0) {
const step = tickIncrement(start, stop, count);
if (step === prestep) {
d[i0] = start
Expand All @@ -46,10 +46,12 @@ export function linearish(scale) {
start = Math.ceil(start * step) / step;
stop = Math.floor(stop * step) / step;
} else {
return scale;
break;
}
prestep = step;
}

return scale;
};

return scale;
Expand Down

0 comments on commit 96b8f4b

Please sign in to comment.