Skip to content

Fix label auto-angling for unsorted array tickvals - #8223

Closed
toyeshhm wants to merge 2 commits into
plotly:mainfrom
toyeshhm:fix-7414-unsorted-tickvals-overlap
Closed

toyeshhm wants to merge 2 commits into
plotly:mainfrom
toyeshhm:fix-7414-unsorted-tickvals-overlap

Conversation

@toyeshhm

@toyeshhm toyeshhm commented Dec 2, 2026 •

Copy link
Copy Markdown

Fixes #7414.

When an axis uses tickmode: 'array' with tickvals that aren't sorted, long ticktext labels can overlap without being auto-angled the way they are when the same values are sorted.

Root cause. arrayTicks() returns the ticks in the order the user gave in tickvals. fixLabelOverlaps() in drawLabels then assumes neighboring entries are neighbors on the axis: it only tests lbbArray[i] against lbbArray[i + 1], and it takes the tick spacing from (vals[last].x - vals[0].x) / (n - 1). With unsorted values both are wrong, so the chosen angle doesn't match the sorted case (with [3, 0, 5, 1, 4, 2] the spacing comes out tiny and the labels go to 90° instead of 30°, and other orders can miss the overlap entirely).

Fix. Sort the ticks by position at the end of arrayTicks(), before filterRangeBreaks. Each tick's text is resolved before the sort, so the ticktext pairing is unchanged. Auto-generated ticks are already in axis order, so this makes array ticks match what the rest of the drawing code expects.

Test. Added a case in test/jasmine/tests/axes_test.js (test tickmode calculator > arrayTicks) that plots the same long labels with sorted and unsorted tickvals. It checks that the unsorted axis gets the same _tickAngles.xtick (30°) as the sorted one and that _vals come out in axis order with the right text. Before the fix it fails with Expected 90 to be close to 30; after, it passes.

npm run test-jasmine -- axes polar ternary colorbar --nowatch passes except for more react tests insiderange react to new data and one @gl polar drag test, which fail the same way on main locally. npm run lint and npm run test-syntax pass.

Copilot AI balanced review requested due to automatic review settings December 2, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

@toyeshhm, thanks for contributing to our project! To help us manage a large volume of pull requests, we do require that you follow our guidelines in CONTRIBUTING.md.

The linked issue #7414 doesn't have the ready-for-pr label. Since we don't have the resources to review this pull request right now, we're closing it.

To continue:

  1. Request that a maintainer add the ready-for-pr label and assign the issue to you
  2. Ask a maintainer to reopen this pull request

@github-actions github-actions Bot closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsorted tickvals do not avoid ticktext overlaps

2 participants