diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 38a8a7a8909..8b4446e4c65 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -2210,9 +2210,9 @@ function numFormat(v, ax, fmtoverride, hover) { v = v.slice(0, Math.max(0, v.length + tickRound)); for(var i = tickRound; i < 0; i++) v += '0'; } else { - v = String(v); - var dp = v.indexOf('.') + 1; - if(dp) v = v.slice(0, dp + tickRound).replace(/\.?0+$/, ''); + // subtract the half-epsilon added above so toFixed doesn't double-round + v -= e; + v = v.toFixed(Math.min(20, tickRound)).replace(/\.?0+$/, ''); } // insert appropriate decimal point and thousands separator v = Lib.numSeparate(v, ax._separators, separatethousands);