Skip to content

Commit

Permalink
Fix ticks for small log domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 23, 2019
1 parent cf2c15b commit a8ef733
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/log.js
Expand Up @@ -102,7 +102,7 @@ export function loggish(transform) {
z.push(t);
}
}
if (!z.length) z = ticks(u, v, n);
if (z.length * 2 < n) z = ticks(u, v, n);
} else {
z = ticks(i, j, Math.min(j - i, n)).map(pows);
}
Expand Down
5 changes: 5 additions & 0 deletions test/log-test.js
Expand Up @@ -296,6 +296,11 @@ tape("log.ticks() generates the expected power-of-ten ticks for small domains",
test.deepEqual(s.domain([5, 1]).ticks(), [5, 4, 3, 2, 1]);
test.deepEqual(s.domain([-1, -5]).ticks(), [-1, -2, -3, -4, -5]);
test.deepEqual(s.domain([-5, -1]).ticks(), [-5, -4, -3, -2, -1]);
test.deepEqual(s.domain([286.9252014, 329.4978332]).ticks(1), [300]);
test.deepEqual(s.domain([286.9252014, 329.4978332]).ticks(2), [300]);
test.deepEqual(s.domain([286.9252014, 329.4978332]).ticks(3), [300, 320]);
test.deepEqual(s.domain([286.9252014, 329.4978332]).ticks(4), [290, 300, 310, 320]);
test.deepEqual(s.domain([286.9252014, 329.4978332]).ticks(), [290, 295, 300, 305, 310, 315, 320, 325]);
test.end();
});

Expand Down

0 comments on commit a8ef733

Please sign in to comment.