Skip to content

Commit 93baa6e

Browse files
committed
Fix ticklabelindex positioning if major and minor ticks aren't aligned.
1 parent 0ff997f commit 93baa6e

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

‎src/plots/cartesian/axes.js‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,18 +1205,12 @@ axes.calcTicks = function calcTicks(ax, opts) {
12051205
// For each major tick, find the minor tick `ticklabelIndex` steps away.
12061206
// This minor tick will be labeled instead of the major tick.
12071207

1208-
const labelTickValsAscending = minorTickVals
1209-
.map((minor) => {
1210-
// if there is a major tick at the same position, prefer it over the minor tick because overlapping minor ticks are stripped away
1211-
// if both minor and major ticks are drawn on the same side.
1212-
const major = findOverlappingTick(minor, tickVals);
1213-
if (major) {
1214-
return major;
1215-
}
1216-
return minor;
1217-
})
1218-
.slice()
1219-
.sort((a, b) => a.value - b.value);
1208+
// if a minor tick coincides with a major tick, prefer it over the minor tick
1209+
// because overlapping minor ticks are stripped away if both minor and major ticks are drawn on the same side.
1210+
const filteredMinors = minorTickVals.filter((minor) => findOverlappingTick(minor, tickVals) == null);
1211+
const labelTickValsAscending = tickVals.concat(filteredMinors)
1212+
.slice()
1213+
.sort((a, b) => a.value - b.value);
12201214

12211215
if (isPeriod && tickVals.length) {
12221216
// first major tick was just added for period handling

0 commit comments

Comments
 (0)