Skip to content

Commit

Permalink
clamps argument of toExponential between 0 and 20 (chartjs#6423)
Browse files Browse the repository at this point in the history
  • Loading branch information
veggiesaurus authored and etimberg committed Aug 3, 2019
1 parent 051fdbb commit 0f4ca63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/core.ticks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ module.exports = {
var maxTick = Math.max(Math.abs(ticks[0]), Math.abs(ticks[ticks.length - 1]));
if (maxTick < 1e-4) { // all ticks are small numbers; use scientific notation
var logTick = helpers.log10(Math.abs(tickValue));
tickString = tickValue.toExponential(Math.floor(logTick) - Math.floor(logDelta));
var numExponential = Math.floor(logTick) - Math.floor(logDelta);
numExponential = Math.max(Math.min(numExponential, 20), 0);
tickString = tickValue.toExponential(numExponential);
} else {
var numDecimal = -1 * Math.floor(logDelta);
numDecimal = Math.max(Math.min(numDecimal, 20), 0); // toFixed has a max of 20 decimal places
Expand Down

0 comments on commit 0f4ca63

Please sign in to comment.