Skip to content

Commit bc032db

Browse files
committed
Subtract rounding increment when using toFixed
1 parent 8908ff9 commit bc032db

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/plots/cartesian/axes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,9 @@ function numFormat(v, ax, fmtoverride, hover) {
22102210
v = v.slice(0, Math.max(0, v.length + tickRound));
22112211
for(var i = tickRound; i < 0; i++) v += '0';
22122212
} else {
2213-
v = v.toFixed(Math.max(0, Math.min(20, tickRound))).replace(/\.?0+$/, '');
2213+
// subtract the half-epsilon added above so toFixed doesn't double-round
2214+
v -= e;
2215+
v = v.toFixed(Math.min(20, tickRound)).replace(/\.?0+$/, '');
22142216
}
22152217
// insert appropriate decimal point and thousands separator
22162218
v = Lib.numSeparate(v, ax._separators, separatethousands);

0 commit comments

Comments
 (0)