fix(Tooltip): find the active sector in the angle-axis wrap-around gap#7550
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughFull-circle ChangesAngle-axis interval matching
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle ReportChanges will increase total bundle size by 3.23kB (0.06%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-umdAssets Changed:
view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-treeshaking-sunburstAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-treeshaking-sankeyAssets Changed:
view changes for bundle: recharts/bundle-treeshaking-treemapAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7550 +/- ##
=======================================
Coverage 88.18% 88.19%
=======================================
Files 613 613
Lines 14258 14260 +2
Branches 3589 3588 -1
=======================================
+ Hits 12574 12576 +2
Misses 1494 1494
Partials 190 190 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
On a full-circle angle axis,
calculateActiveTickIndexcan return -1 for pointer angles near the range wrap, so hovering that part of a PieChart produces no active sector —onMouseMovegets no coordinates and the tooltip doesn't show. This is the calculation ckifer pinned down in the issue: tooltip ticks get shifted by the band offset (±4° for a 4-sector pie), which moves the first/last tick intervals partially out of the [0, 360] window. The pointer angle is always normalized into that window, so the slice between the last covered boundary and 360° (356°–360° in the 4-sector case, the "bottom right" from the reports) matches no interval and falls through to -1.Zeroing the offset fixes pie but breaks RadarChart (as noted in the thread), so this fix leaves the offset alone and instead makes the interval matching wrap-aware: the coordinate is also tested shifted by a full turn in both directions. It's strictly widening — every coordinate that matched before still matches the same sector (the intervals partition the circle, so the shifted candidates can't produce a conflicting match), and only the previously-dead gap gains coverage.
Related Issue
Fixes #5099
Motivation and Context
Hovering near the wrap of a full-circle pie silently loses the tooltip/mouse coordinates even though the pointer is inside a sector.
How Has This Been Tested?
Unit tests in
test/util/ChartUtils.spec.tsxusing the exact tick shape the tooltip selector produces for a 4-sector pie (band starts shifted by -4, range [0, 360]): three pointer angles inside the wrap gap (357, 358, 359.9) return -1 on current main and sector 0 with this change, and five control angles across all sectors return the same index before and after the change. Also ran the full polar surface as a guard for the RadarChart concern from the thread:test/polar/,PieChart,RadarChart,RadialBarChart(19 files, 522 tests), plustest/state/and the Tooltip component suites (64 files, 1236 tests),tsc, and eslint — all green.Screenshots (if appropriate):
n/a
Types of changes
Checklist:
Summary by CodeRabbit
Bug Fixes
Tests