Skip to content

Commit a46dd96

Browse files
veggiesaurusetimberg
authored andcommitted
clamps argument of toExponential between 0 and 20 (#6423)
1 parent 6632b8b commit a46dd96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/core/core.ticks.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ module.exports = {
4949
var maxTick = Math.max(Math.abs(ticks[0]), Math.abs(ticks[ticks.length - 1]));
5050
if (maxTick < 1e-4) { // all ticks are small numbers; use scientific notation
5151
var logTick = helpers.log10(Math.abs(tickValue));
52-
tickString = tickValue.toExponential(Math.floor(logTick) - Math.floor(logDelta));
52+
var numExponential = Math.floor(logTick) - Math.floor(logDelta);
53+
numExponential = Math.max(Math.min(numExponential, 20), 0);
54+
tickString = tickValue.toExponential(numExponential);
5355
} else {
5456
var numDecimal = -1 * Math.floor(logDelta);
5557
numDecimal = Math.max(Math.min(numDecimal, 20), 0); // toFixed has a max of 20 decimal places

0 commit comments

Comments
 (0)