Skip to content

Commit a3cc377

Browse files
committed
Fix accidental drawing of additional minor tick before tick0.
This additional minor tick was added for ticklabel placement via ticklabelindex only. It should never be rendered.
1 parent 081da50 commit a3cc377

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/plots/cartesian/axes.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,11 @@ axes.calcTicks = function calcTicks(ax, opts) {
10761076
}
10771077
}
10781078

1079-
if((major || calcMinor) && isPeriod) {
1080-
// add one item to label period before tick0
1079+
if((major || ticklabelIndex) && isPeriod) {
1080+
// if major: add one item to label period before tick0
1081+
// if minor: add one item for ticklabelindex positioning
10811082
x = axes.tickIncrement(x, dtick, !axrev, calendar);
1082-
majorId--;
1083+
if (major) majorId--;
10831084
}
10841085

10851086
for(;
@@ -1128,12 +1129,14 @@ axes.calcTicks = function calcTicks(ax, opts) {
11281129
}
11291130

11301131
// check if ticklabelIndex makes sense, otherwise ignore it
1131-
if(!minorTickVals || minorTickVals.length < 2) {
1132+
if(!minorTickVals || minorTickVals.length < 3) {
11321133
ticklabelIndex = false;
11331134
} else {
1134-
var diff = (minorTickVals[1].value - minorTickVals[0].value) * (isReversed ? -1 : 1);
1135+
var diff = (minorTickVals[2].value - minorTickVals[1].value) * (isReversed ? -1 : 1);
11351136
if(!periodCompatibleWithTickformat(diff, ax.tickformat)) {
11361137
ticklabelIndex = false;
1138+
// remove previously added tick before tick0 for handling ticklabelindex positioning
1139+
minorTickVals = minorTickVals.slice(1);
11371140
}
11381141
}
11391142
// Determine for which ticks to draw labels
@@ -1313,6 +1316,11 @@ axes.calcTicks = function calcTicks(ax, opts) {
13131316
ticksOut.push(t);
13141317
}
13151318
}
1319+
1320+
if(isPeriod && ticklabelIndex && minorTicks.length) {
1321+
// drop very first minor tick that we added to handle ticklabelindex
1322+
minorTicks[0].noTick = true;
1323+
}
13161324
ticksOut = ticksOut.concat(minorTicks);
13171325

13181326
ax._inCalcTicks = false;

0 commit comments

Comments
 (0)