Skip to content

Commit bae4f11

Browse files
committed
use defined minor.ntick to divide delta without rounding
1 parent 4d72fa5 commit bae4f11

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/plots/cartesian/axes.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
849849
} else {
850850
ax.minor._dtickInit = ax.minor.dtick;
851851
ax.minor._tick0Init = ax.minor.tick0;
852+
ax.minor._ntickInit = ax.minor.ntick;
852853
}
853854

854855
var mockAx = major ? ax : Lib.extendFlat({}, ax, ax.minor);
@@ -858,6 +859,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
858859
mockAx._majorDtick = ax.dtick;
859860
mockAx.dtick = mockAx._dtickInit;
860861
mockAx.tick0 = mockAx._tick0Init;
862+
mockAx.ntick = mockAx._ntickInit;
861863
}
862864
}
863865

@@ -1015,9 +1017,9 @@ axes.calcTicks = function calcTicks(ax, opts) {
10151017
var found = false;
10161018
for(var q = 0; !found && (q < tickVals.length); q++) {
10171019
if(
1018-
// add 1000 to eliminate problematic digits
1019-
1000 + tickVals[q].value ===
1020-
1000 + v
1020+
// add 10e6 to eliminate problematic digits
1021+
10e6 + tickVals[q].value ===
1022+
10e6 + v
10211023
) {
10221024
found = true;
10231025
}
@@ -1344,8 +1346,13 @@ axes.autoTicks = function(ax, roughDTick, isMinor) {
13441346
} else {
13451347
// auto ticks always start at 0
13461348
ax.tick0 = 0;
1347-
base = getBase(10);
1348-
ax.dtick = roundDTick(roughDTick, base, roundBase10);
1349+
if(isMinor && ax.nticks) {
1350+
// do not round when minor has nticks in this case
1351+
ax.dtick = roughDTick;
1352+
} else {
1353+
base = getBase(10);
1354+
ax.dtick = roundDTick(roughDTick, base, roundBase10);
1355+
}
13491356
}
13501357

13511358
// prevent infinite loops

0 commit comments

Comments
 (0)