Skip to content

Fix intersect hit testing on descending index-scale pixels - #12358

Open
hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix/descending-interaction-bounds
Open

hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix/descending-interaction-bounds

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 25, 2026

Copy link
Copy Markdown

Description

The shared-options branch in interaction's binary search searches value - range for the start index and value + range for the end index. Those bounds are in the opposite order when the index scale's pixel coordinates descend, such as a reversed x scale or an ordinary vertical y index scale. As a result, point interaction can return no elements even when several points overlap the event.

Apply the pixel direction to the range before choosing the bounds. This keeps the existing binary-search optimization and avoids changing non-intersecting interaction or datasets without shared options.

Tests

Added four cases for x/y index axes with reverse enabled and disabled. Each compares point interaction with direct inRange hit testing at three positions. The tests assert sorted data and shared options so they exercise the optimized branch.

  • On unchanged master, the reversed-x and ordinary-y cases fail in Chrome and Firefox (2 failures per browser). With the fix, all 52 interaction tests pass in each browser.
  • All 423 core tests pass in each browser: 846 total.
  • pnpm lint, including JavaScript/Markdown lint, build/declaration generation and type tests, passes with existing warnings.
  • The complete all-spec browser run exceeded this environment's 120-second execution limit and was stopped; it is not claimed as passing.

A rendered comparison using the unchanged and patched builds confirms the example returns 0 of 3 overlapping points before the fix and all 3 after it.

hakarrr and others added 2 commits October 25, 2026 18:54
Apply the index scale's pixel direction when choosing the binary-search bounds, so overlapping points remain selectable on reversed x and ordinary vertical y index scales.

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Compare optimized point interaction with direct hit testing at three positions on x/y index scales, with reverse enabled and disabled. Confirm sorted data and shared options exercise ranged binary search.

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
@hakarrr

hakarrr commented Oct 29, 2026

Copy link
Copy Markdown
Author

Could you review this reversed-index interaction fix when you have time? The separate final-animation-position lookup (#12359), epoch-zero time bounds (#12360), and logarithmic zero-state reset (#12361) fixes are also awaiting review. Each description records its own regression results and validation limits; the hosted CI and Compressed Size runs still require maintainer approval. Grouping this follow-up here rather than repeating it on each PR. Please let me know if changes are needed. Thanks.

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.

1 participant