Skip to content

fix: enable tooltip synchronization for PieChart#6989

Merged
PavelVanecek merged 1 commit intorecharts:mainfrom
VIDHITTS:fix/pie-chart-tooltip-sync
Feb 13, 2026
Merged

fix: enable tooltip synchronization for PieChart#6989
PavelVanecek merged 1 commit intorecharts:mainfrom
VIDHITTS:fix/pie-chart-tooltip-sync

Conversation

@VIDHITTS
Copy link
Contributor

@VIDHITTS VIDHITTS commented Feb 11, 2026

Description

Fix tooltip synchronization for PieChart (and other item-type charts like ScatterChart/FunnelChart).

When two PieCharts share a syncId, hovering on the first chart should display a tooltip on the second — but currently no tooltip appears on the receiving chart. This was a known issue explicitly marked as TODO in the test suite.

Root Cause

Two bugs in the tooltip sync pipeline:

  1. combineTooltipPayloadConfigurations filters payloads by graphicalItemId from itemInteraction.hover, but on the receiving chart the interaction arrives via syncInteraction — so filterByGraphicalItemId is undefined and the filter returns an empty array → no tooltip.

  2. useTooltipChartSynchronisation always sets graphicalItemId: undefined in sync events, never forwarding the source chart's active item ID.

Changes

  • Add sync-aware fallback in combineTooltipPayloadConfigurations so receiving charts show tooltip items when syncInteraction is active
  • Pass activeGraphicalItemId through sync events instead of undefined
  • Uncomment and enable PieChart sync test case

Related Issue

Tooltip synchronization for Pie, Scatter, and Funnel charts was marked as a TODO in Tooltip.sync.spec.tsx.

Fixes #6863

Motivation and Context

PieChart tooltip sync was broken in Recharts v3. Users with synced PieCharts saw no tooltip on the receiving chart when hovering the first.

How Has This Been Tested?

  • Uncommented and enabled the existing PieChartTestCase in Tooltip.sync.spec.tsx
  • All 102 tooltip sync tests pass (4 pre-existing skips), zero regressions
  • Full test suite: 13,878 tests pass (16 skipped, 2 todo)
  • Type checking passes across all projects (lib, test, storybook, website)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

Summary by CodeRabbit

  • Bug Fixes

    • Tooltip synchronization now shows all items at the synced index when no specific item filter is applied.
    • Tooltip synchronization correctly uses the currently active graphical item when emitting sync events.
  • New Features

    • Added PieChart support for tooltip synchronization and updated tests to cover radial charts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

Adds support for synchronized tooltips for pie charts by including the active graphical item id in tooltip sync events and adjusting payload combining to return all tooltip items when synchronization is active without a graphicalItemId filter.

Changes

Cohort / File(s) Summary
Tooltip payload combiner
src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts
Adds branch: when tooltipState.syncInteraction.active is true and filterByGraphicalItemId is null, return all tooltipItemPayloads instead of filtering by graphicalItemId.
Tooltip synchronization hook
src/synchronisation/useChartSynchronisation.tsx
Includes selectActiveTooltipGraphicalItemId; sends graphicalItemId: activeGraphicalItemId in TOOLTIP_SYNC_EVENT and adds it to effect deps.
Tests: tooltip sync
test/component/Tooltip/Tooltip.sync.spec.tsx
Enables PieChart tests: imports Pie/PieChart, adds pie selector, introduces PieChartTestCase (dataKey), and updates radial test cases and expectations.

Sequence Diagram(s)

sequenceDiagram
    participant User as User (hover)
    participant Source as SourceChart
    participant Sync as SyncService
    participant Target as TargetChart

    User->>Source: hover sector
    Source->>Source: determine activeGraphicalItemId
    Source->>Sync: emit TOOLTIP_SYNC_EVENT { index, activeGraphicalItemId, syncInteraction.active }
    Sync->>Target: forward sync event
    Target->>Target: combineTooltipPayloadConfigurations(syncActive=true, filterByGraphicalItemId=null)
    Target-->>Target: return all tooltipItemPayloads for synced index
    Target->>User: display synced tooltip
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • PavelVanecek
  • ckifer
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: enable tooltip synchronization for PieChart' clearly and specifically summarizes the main change in the PR.
Description check ✅ Passed The PR description is well-structured with all key template sections completed: Description, Related Issue, Motivation and Context, How Has This Been Tested, and Types of changes are all thoroughly filled out.
Linked Issues check ✅ Passed All code changes directly address issue #6863: combineTooltipPayloadConfigurations adds sync-aware fallback logic, useChartSynchronisation forwards activeGraphicalItemId, and Tooltip.sync.spec.tsx enables PieChart test case.
Out of Scope Changes check ✅ Passed All three modified files contain changes directly aligned with fixing tooltip synchronization for PieChart; no unrelated modifications detected outside the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts`:
- Around line 42-50: The current ordering in combineTooltipPayloadConfigurations
causes the defaultIndex branch (when defaultIndex is set and
filterByGraphicalItemId is null) to short-circuit before syncInteraction logic,
so a synced tooltip is ignored when a defaultIndex exists; either move the
syncInteraction check (tooltipState.syncInteraction.active) to run before the
defaultIndex check so synced events take precedence over defaultIndex, or if the
current ordering is intentional add a clarifying comment above the defaultIndex
branch mentioning why defaultIndex must override syncInteraction; update
references in the function to tooltipState, filterByGraphicalItemId,
defaultIndex and syncInteraction accordingly.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (bff7456) to head (cae6ac7).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6989   +/-   ##
=======================================
  Coverage   90.10%   90.10%           
=======================================
  Files         522      522           
  Lines       38844    38853    +9     
  Branches     5347     5349    +2     
=======================================
+ Hits        35000    35009    +9     
  Misses       3835     3835           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add sync-aware fallback in combineTooltipPayloadConfigurations
  so receiving charts show tooltip items when syncInteraction is active
- Pass activeGraphicalItemId through sync events instead of undefined
- Uncomment and enable PieChart sync test case
@VIDHITTS VIDHITTS force-pushed the fix/pie-chart-tooltip-sync branch from 3f78c9d to cae6ac7 Compare February 11, 2026 04:55
Copy link
Collaborator

@PavelVanecek PavelVanecek left a comment

Choose a reason for hiding this comment

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

Looks easier than I thought it would be. Thanks!

@PavelVanecek PavelVanecek merged commit 8042617 into recharts:main Feb 13, 2026
41 checks passed
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.

Missing Tooltip in sync Pie charts

2 participants