Skip to content

Commit db2dab9

Browse files
committed
ticklabelindex: refine label visibility check
For period axes, a label is visible if one of the enclosing ticks is visible.
1 parent a2afbf0 commit db2dab9

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/plots/cartesian/axes.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,21 @@ axes.calcTicks = function calcTicks(ax, opts) {
11831183
const smallerMinorTicks = minorTickValsAscending.filter((minorTick) => minorTick.value <= majorTick.value);
11841184
const absLabelIndex = Math.abs(labelIndex);
11851185
const minorTickIndex = smallerMinorTicks.length - absLabelIndex - 1;
1186-
if (absLabelIndex <= smallerMinorTicks.length - 1 && !smallerMinorTicks[minorTickIndex].noTick) {
1187-
allTicklabelVals.push(smallerMinorTicks[minorTickIndex]);
1188-
if (isPeriod) periodEndTicks.push(smallerMinorTicks[minorTickIndex + 1]);
1186+
if (absLabelIndex <= smallerMinorTicks.length - 1) {
1187+
const labelVisible = !smallerMinorTicks[minorTickIndex].noTick || (isPeriod && !smallerMinorTicks[minorTickIndex + 1].noTick);
1188+
if (labelVisible) {
1189+
allTicklabelVals.push(smallerMinorTicks[minorTickIndex]);
1190+
if (isPeriod) periodEndTicks.push(smallerMinorTicks[minorTickIndex + 1]);
1191+
}
11891192
}
11901193
} else { // labelIndex >= 0
11911194
const largerMinorTicks = minorTickValsAscending.filter((minorTick) => minorTick.value >= majorTick.value);
1192-
if (labelIndex < largerMinorTicks.length - 1 && !largerMinorTicks[labelIndex].noTick) {
1193-
allTicklabelVals.push(largerMinorTicks[labelIndex]);
1194-
if (isPeriod) periodEndTicks.push(largerMinorTicks[labelIndex + 1]);
1195+
if (labelIndex < largerMinorTicks.length - 1) {
1196+
const labelVisible = !largerMinorTicks[labelIndex].noTick || (isPeriod && !largerMinorTicks[labelIndex + 1].noTick);
1197+
if (labelVisible) {
1198+
allTicklabelVals.push(largerMinorTicks[labelIndex]);
1199+
if (isPeriod) periodEndTicks.push(largerMinorTicks[labelIndex + 1]);
1200+
}
11951201
}
11961202
}
11971203
majorTick.skipLabel = true;

0 commit comments

Comments
 (0)