Skip to content

Commit af9a2f3

Browse files
committed
Explain in comments why minor ticks need an additional tick in the case of ticklabelindex.
1 parent f5700e9 commit af9a2f3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/plots/cartesian/axes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,9 @@ axes.calcTicks = function calcTicks(ax, opts) {
10781078

10791079
if((major || ticklabelIndex) && isPeriod) {
10801080
// if major: add one item to label period before tick0
1081-
// if minor: add one item for ticklabelindex positioning
1081+
// if minor: add one item for ticklabelindex positioning. positionPeriodTicks requires
1082+
// at least 2 ticks to calculate the period length, so we add a dummy tick, ensuring
1083+
// that if a tick is labeled, there are always at least 2 ticks.
10821084
x = axes.tickIncrement(x, dtick, !axrev, calendar);
10831085
if (major) majorId--;
10841086
}
@@ -1128,7 +1130,9 @@ axes.calcTicks = function calcTicks(ax, opts) {
11281130
}
11291131
}
11301132

1131-
// check if ticklabelIndex makes sense, otherwise ignore it
1133+
// check if ticklabelIndex makes sense, otherwise ignore it.
1134+
// It makes sense if in addition to the always present dummy, there are at least 2 minor ticks
1135+
// with the required distance to each other.
11321136
if(!minorTickVals || minorTickVals.length < 3) {
11331137
ticklabelIndex = false;
11341138
} else {

0 commit comments

Comments
 (0)