Skip to content

Add graphicalItemId to tooltip payload object#6765

Merged
ckifer merged 2 commits intomainfrom
graphical-item-id
Dec 12, 2025
Merged

Add graphicalItemId to tooltip payload object#6765
ckifer merged 2 commits intomainfrom
graphical-item-id

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Dec 12, 2025

Description

No bugfixes yet, just wiring the graphicalItemId in tooltip payload where it will be useful for fixing bugs later.

Related Issue

#6075

Motivation and Context

In several PRs recently this came up as a change that would be useful but nobody wanted to do that because it's too big! So I did.

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

Release Notes

  • New Features
    • Chart elements (Area, Bar, Line, Scatter, Pie, Funnel, Sankey, Sunburst, Treemap, Radar, RadialBar) now support optional id prop for explicit identification and improved tooltip linking.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

This pull request introduces a graphical item identification system to Recharts, replacing dataKey-based tracking with a unique graphicalItemId for each chart component. Components now support an optional id prop, auto-generated via RegisterGraphicalItemId when not provided, and this ID flows through tooltip payloads, event handlers, and state selectors for consistent item tracking across interactions.

Changes

Cohort / File(s) Summary
Core Constants & Utilities
src/util/Constants.ts, test/helper/mockTouchingElement.ts
Replaced DATA_ITEM_DATAKEY_ATTRIBUTE_NAME with DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME; updated mock helper to accept graphicalItemId parameter instead of dataKey.
State & Selectors
src/state/touchEventsMiddleware.ts, src/state/selectors/touchSelectors.ts, src/state/selectors/funnelSelectors.ts
Updated touch event middleware to read graphicalItemId from DOM and use it for coordinate lookup; changed selectTooltipCoordinate signature to accept graphicalItemId instead of dataKey; extended ResolvedFunnelSettings with id field and updated selectFunnelTrapezoids to pass it through.
Tooltip Payload Types
src/component/DefaultTooltipContent.tsx
Added required graphicalItemId: string field to Payload interface.
Cartesian Components
src/cartesian/Area.tsx, src/cartesian/Bar.tsx, src/cartesian/Line.tsx, src/cartesian/Scatter.tsx
Introduced GraphicalItemId typing for internal id properties; extended SetTooltipEntrySettings components to accept and propagate id as graphicalItemId in tooltip payloads.
Polar Components
src/polar/Pie.tsx, src/polar/Radar.tsx, src/polar/RadialBar.tsx
Updated tooltip entry settings to accept and include id as graphicalItemId in tooltip configurations; adjusted rendering to pass id through tooltip pipelines.
Complex Chart Components
src/cartesian/Funnel.tsx
Refactored from class-based to functional component with RegisterGraphicalItemId wrapper; added id: GraphicalItemId to internal props; extended tooltip setup to propagate graphicalItemId.
Other Chart Components
src/chart/Sankey.tsx, src/chart/SunburstChart.tsx, src/chart/Treemap.tsx
Introduced RegisterGraphicalItemId wrappers and updated internal prop types (InternalSankeyProps, etc.) to include id: GraphicalItemId; extended tooltip settings to carry graphicalItemId.
Cartesian Component Tests
test/cartesian/Area.spec.tsx, test/cartesian/Bar.spec.tsx, test/cartesian/Line.spec.tsx, test/cartesian/Scatter.spec.tsx
Updated tooltip payload assertions to include graphicalItemId matching patterns like /^recharts-area-.+/; added type annotations for TooltipPayloadConfiguration.
Chart Integration Tests
test/chart/LineChart.spec.tsx, test/chart/ScatterChart.spec.tsx, test/chart/Treemap.spec.tsx
Added explicit id props to chart components and updated expected payloads/event arguments to include corresponding graphicalItemId values.
Tooltip Component Tests
test/component/Tooltip/Tooltip.*.spec.tsx, test/component/DefaultTooltipContent.spec.tsx, test/component/Cursor.spec.tsx
Added id props to chart series elements (Area, Bar, Line, Scatter, Pie, Radar, RadialBar); updated payload assertions to expect graphicalItemId fields; exported DefaultTooltipContentProps type.
Selector & Payload Tests
test/component/Tooltip/itemSorter.spec.tsx, test/component/Tooltip/defaultIndex.spec.tsx, test/component/Tooltip/Tooltip.payload.spec.tsx, test/state/selectors/pieSelectors.spec.tsx, test/state/selectors/selectors.spec.tsx
Added graphicalItemId fields to tooltip payload configuration expectations across multiple test cases; introduced graphicalItemId as an optional field to TooltipPayloadConfiguration and TooltipPayloadEntry types.
Polar Component Tests
test/polar/Pie.spec.tsx
Replaced attribute constant usage with DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME; added id props to Pie components; updated active shape and tooltip payload assertions to include graphicalItemId.
Omnidoc Tests
omnidoc/readProject.spec.ts
Updated expected properties snapshot for Funnel component to reflect narrower public surface.

Sequence Diagram

sequenceDiagram
    participant User as User Interaction
    participant DOM as DOM Element
    participant Middleware as Touch Event Middleware
    participant Selector as Tooltip Selectors
    participant Store as Redux Store
    participant Tooltip as Tooltip Component
    participant Payload as Tooltip Payload

    User->>DOM: Touch/Mouse on Chart Item
    DOM->>Middleware: Event triggered (graphicalItemId attribute)
    Middleware->>DOM: Read graphicalItemId from element
    Middleware->>Store: selectAllGraphicalItemsSettings(state)
    Store-->>Middleware: Settings with matching graphicalItemId
    Middleware->>Selector: selectTooltipCoordinate(state, tooltipIndex, graphicalItemId)
    Selector->>Store: Query tooltipConfiguration by graphicalItemId
    Store-->>Selector: Find matching configuration
    Selector-->>Middleware: Return coordinate
    Middleware->>Store: Dispatch activeMouseOverItemIndex with graphicalItemId
    Store->>Tooltip: Update tooltip state
    Tooltip->>Payload: Render with graphicalItemId in payload entries
    Payload->>User: Display tooltip with item identification
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas requiring extra attention:

  • Funnel.tsx refactoring: Major shift from class-based to functional component with RegisterGraphicalItemId wrapper; verify id flow through FunnelImpl, RenderTrapezoids, and tooltip setup is correct.
  • Touch event middleware integration: Verify that selectAllGraphicalItemsSettings lookup and dataKey extraction from settings work correctly in all interaction scenarios.
  • Selector signature changes: selectTooltipCoordinate and selectFunnelTrapezoids now accept different parameters; ensure all call sites are updated.
  • Type consistency: GraphicalItemId vs string id handling across components (especially Treemap, Sankey, SunburstChart where both explicit and auto-generated IDs are used).
  • Test coverage breadth: Extensive test updates across tooltip, payload, and selector tests—verify assertions for graphicalItemId regex patterns and value propagation are exhaustive.

Possibly related PRs

Suggested labels

enhancement, feature request

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and directly describes the main change: adding graphicalItemId to tooltip payload object, which is the primary focus of this PR.
Description check ✅ Passed The description provides context, related issue, motivation, and indicates tests were added. However, most template sections remain unchecked or incomplete (Related Issue, Motivation, and How Has This Been Tested sections lack full details).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch graphical-item-id

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/component/DefaultTooltipContent.tsx (1)

27-48: Making graphicalItemId required is TypeScript-breaking; make it optional (or provide a compat path)
Payload is exported, so changing it to require graphicalItemId will break consumers at compile time. Suggest graphicalItemId?: string (and ensure internal payload construction always sets it).

src/cartesian/Scatter.tsx (1)

414-428: Pass id into tooltip dispatch hooks so interactions carry activeGraphicalItemId.
Right now hover/click dispatches don’t include the graphical item ID even though the hook supports it; this can reintroduce ambiguity when multiple scatters share a dataKey.

 function ScatterSymbols(props: ScatterSymbolsProps) {
   const { points, allOtherScatterProps } = props;
   const { shape, activeShape, dataKey } = allOtherScatterProps;
 
   const activeIndex = useAppSelector(selectActiveTooltipIndex);
+  const { id, ...allOtherPropsWithoutId } = allOtherScatterProps;
   const {
     onMouseEnter: onMouseEnterFromProps,
     onClick: onItemClickFromProps,
     onMouseLeave: onMouseLeaveFromProps,
     ...restOfAllOtherProps
   } = allOtherScatterProps;
 
-  const onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey);
+  const onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey, id);
   const onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
-  const onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey);
+  const onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey, id);
   if (!isNonEmptyArray(points)) {
     return null;
   }
 
-  const { id, ...allOtherPropsWithoutId } = allOtherScatterProps;
   const baseProps = svgPropertiesNoEvents(allOtherPropsWithoutId);
🧹 Nitpick comments (8)
src/state/touchEventsMiddleware.ts (1)

9-68: Avoid per-touch linear scan over all graphical items (and skip work when id missing)
This will run on touchMove, so selectAllGraphicalItemsSettings(state).find(...) can become a hot path on busy charts. Consider a selector keyed by graphicalItemId (e.g., an id→settings map) and early-return before searching when graphicalItemId is nullish.

src/chart/SunburstChart.tsx (1)

247-276: Consider threading the resolved id into click/hover actions (activeGraphicalItemId) for parity with other charts.
This likely needs moving the event handlers into the RegisterGraphicalItemId callback (so they can capture id).

Also applies to: 365-380

src/cartesian/Line.tsx (1)

68-120: Type alignment for internal id looks correct, but consider using GraphicalItemId more consistently across components.
InternalLineProps.id: GraphicalItemId matches the intent (unique graphical identity) and stays compatible since GraphicalItemId is currently a string alias. If GraphicalItemId ever becomes a branded type, this file will be “future-proof” while other components still using string may become inconsistent.

src/cartesian/Area.tsx (1)

1031-1051: Good: Area passes the registered id into tooltip settings (not the optional external prop).
Consider typing internal id as GraphicalItemId (like Line.tsx) to keep the codebase consistent if GraphicalItemId ever stops being a plain string.

src/chart/Sankey.tsx (1)

611-634: Consider adding id to the public SankeyProps interface.

The id prop is now being used via RegisterGraphicalItemId, but it's not explicitly declared in the SankeyProps interface. While it may work due to the SVGProps spread, explicitly adding id?: string; would improve discoverability and documentation for users who want to provide a custom ID.

 interface SankeyProps {
   nameKey?: DataKey<any>;
   dataKey?: DataKey<any>;
   width?: number | Percent;
   height?: number | Percent;
   data: SankeyData;
   nodePadding?: number;
   nodeWidth?: number;
   linkCurvature?: number;
   iterations?: number;
   // TODO object func
   node?: SankeyNodeOptions;
   link?: SankeyLinkOptions;
   style?: React.CSSProperties;
   className?: string;
   children?: ReactNode;
   margin?: Partial<Margin>;
   onClick?: (item: NodeProps | LinkProps, type: SankeyElementType, e: MouseEvent) => void;
   onMouseEnter?: (item: NodeProps | LinkProps, type: SankeyElementType, e: MouseEvent) => void;
   onMouseLeave?: (item: NodeProps | LinkProps, type: SankeyElementType, e: MouseEvent) => void;
   sort?: boolean;
   verticalAlign?: SankeyVerticalAlign;
   align?: 'left' | 'justify';
+  id?: string;
 }
test/helper/mockTouchingElement.ts (2)

1-3: Avoid importing TooltipIndex from internal slice in helpers unless necessary.

If this helper is intended to be broadly reusable, consider taking touchItemIndex: string (or string | number) directly and keep Redux types out of DOM-mocking utilities. This reduces coupling to src/state/tooltipSlice.


18-22: Convert setAttribute values to string (DOM API contract).

Element#setAttribute takes a string value; if TooltipIndex ever includes non-string values, TS/runtime drift is possible. Consider explicit coercion for both attributes:

 export function mockTouchingElement(touchItemIndex: NonNullable<TooltipIndex>, graphicalItemId: GraphicalItemId): void {
   const fakeElement = document.createElement('g');
-  fakeElement.setAttribute(DATA_ITEM_INDEX_ATTRIBUTE_NAME, touchItemIndex);
-  fakeElement.setAttribute(DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME, graphicalItemId);
+  fakeElement.setAttribute(DATA_ITEM_INDEX_ATTRIBUTE_NAME, String(touchItemIndex));
+  fakeElement.setAttribute(DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME, String(graphicalItemId));
   document.elementFromPoint = () => fakeElement;
 }
src/chart/Treemap.tsx (1)

693-698: Good: internal id is a resolved GraphicalItemId via RegisterGraphicalItemId.

One small readability tweak: consider { id: externalId, ...rest } = props to avoid passing id twice (even though the explicit id={id} correctly wins).

Also applies to: 942-955

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 164d6b9 and adfbb6e.

📒 Files selected for processing (36)
  • omnidoc/readProject.spec.ts (1 hunks)
  • src/cartesian/Area.tsx (3 hunks)
  • src/cartesian/Bar.tsx (5 hunks)
  • src/cartesian/Funnel.tsx (16 hunks)
  • src/cartesian/Line.tsx (5 hunks)
  • src/cartesian/Scatter.tsx (7 hunks)
  • src/chart/Sankey.tsx (6 hunks)
  • src/chart/SunburstChart.tsx (6 hunks)
  • src/chart/Treemap.tsx (7 hunks)
  • src/component/DefaultTooltipContent.tsx (1 hunks)
  • src/polar/Pie.tsx (7 hunks)
  • src/polar/Radar.tsx (3 hunks)
  • src/polar/RadialBar.tsx (2 hunks)
  • src/state/selectors/funnelSelectors.ts (4 hunks)
  • src/state/selectors/touchSelectors.ts (1 hunks)
  • src/state/touchEventsMiddleware.ts (2 hunks)
  • src/util/Constants.ts (1 hunks)
  • test/cartesian/Area.spec.tsx (4 hunks)
  • test/cartesian/Bar.spec.tsx (4 hunks)
  • test/cartesian/Line.spec.tsx (1 hunks)
  • test/cartesian/Scatter.spec.tsx (2 hunks)
  • test/chart/LineChart.spec.tsx (2 hunks)
  • test/chart/ScatterChart.spec.tsx (11 hunks)
  • test/chart/Treemap.spec.tsx (3 hunks)
  • test/component/Cursor.spec.tsx (2 hunks)
  • test/component/DefaultTooltipContent.spec.tsx (2 hunks)
  • test/component/Tooltip/Tooltip.content.spec.tsx (6 hunks)
  • test/component/Tooltip/Tooltip.formatter.spec.tsx (6 hunks)
  • test/component/Tooltip/Tooltip.payload.spec.tsx (13 hunks)
  • test/component/Tooltip/Tooltip.visibility.spec.tsx (17 hunks)
  • test/component/Tooltip/defaultIndex.spec.tsx (8 hunks)
  • test/component/Tooltip/itemSorter.spec.tsx (81 hunks)
  • test/helper/mockTouchingElement.ts (2 hunks)
  • test/polar/Pie.spec.tsx (33 hunks)
  • test/state/selectors/pieSelectors.spec.tsx (16 hunks)
  • test/state/selectors/selectors.spec.tsx (20 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

Files:

  • test/cartesian/Bar.spec.tsx
  • omnidoc/readProject.spec.ts
  • test/helper/mockTouchingElement.ts
  • src/state/touchEventsMiddleware.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • src/polar/Pie.tsx
  • test/chart/Treemap.spec.tsx
  • src/util/Constants.ts
  • src/cartesian/Area.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • src/chart/SunburstChart.tsx
  • test/cartesian/Line.spec.tsx
  • src/polar/RadialBar.tsx
  • src/component/DefaultTooltipContent.tsx
  • src/state/selectors/funnelSelectors.ts
  • src/cartesian/Bar.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • src/polar/Radar.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/Treemap.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • src/state/selectors/touchSelectors.ts
  • src/cartesian/Funnel.tsx
  • src/chart/Sankey.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/cartesian/Line.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Aim for 100% unit test code coverage when writing new code

Files:

  • test/cartesian/Bar.spec.tsx
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • test/cartesian/Bar.spec.tsx
  • omnidoc/readProject.spec.ts
  • test/helper/mockTouchingElement.ts
  • src/state/touchEventsMiddleware.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • src/polar/Pie.tsx
  • test/chart/Treemap.spec.tsx
  • src/util/Constants.ts
  • src/cartesian/Area.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • src/chart/SunburstChart.tsx
  • test/cartesian/Line.spec.tsx
  • src/polar/RadialBar.tsx
  • src/component/DefaultTooltipContent.tsx
  • src/state/selectors/funnelSelectors.ts
  • src/cartesian/Bar.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • src/polar/Radar.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/Treemap.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • src/state/selectors/touchSelectors.ts
  • src/cartesian/Funnel.tsx
  • src/chart/Sankey.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/cartesian/Line.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
test/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (test/README.md)

test/**/*.{test,spec}.{ts,tsx}: Aim for 100% unit test code coverage when writing new code
Prefer to use the createSelectorTestCase helper function when writing or modifying tests
Use the expectLastCalledWith helper function instead of expect(spy).toHaveBeenLastCalledWith(...) for better typing and autocompletion
Verify the number of selector calls using the spy object from createSelectorTestCase to spot unnecessary re-renders and improve performance
Mock getBoundingClientRect in tests using the helper function provided in test/helper/MockGetBoundingClientRect.ts
Use vi.useFakeTimers() in all tests due to Redux autoBatchEnhancer dependency on timers and requestAnimationFrame
Call vi.runOnlyPendingTimers() to advance timers after renders when not using createSelectorTestCase helper, and avoid vi.runAllTimers() to prevent infinite loops
Use userEvent.setup({ advanceTimers: vi.runOnlyPendingTimers }) or the userEventSetup helper function from test/helper/userEventSetup.ts when creating userEvent instances
When testing tooltips on hover, use vi.runOnlyPendingTimers() after each userEvent.hover() call or use the showTooltip helper function from tooltipTestHelpers.ts to account for requestAnimationFrame delays

Files:

  • test/cartesian/Bar.spec.tsx
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

When running unit tests, prefer to run a single test file using npm run test -- path/to/TestFile.spec.tsx rather than running all tests with npm test

Files:

  • test/cartesian/Bar.spec.tsx
  • omnidoc/readProject.spec.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

All imports from recharts must use the public API entry point; imports from internal paths like recharts/types/* or recharts/src/* are not allowed

Files:

  • test/cartesian/Bar.spec.tsx
  • omnidoc/readProject.spec.ts
  • test/helper/mockTouchingElement.ts
  • src/state/touchEventsMiddleware.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • src/polar/Pie.tsx
  • test/chart/Treemap.spec.tsx
  • src/util/Constants.ts
  • src/cartesian/Area.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • src/chart/SunburstChart.tsx
  • test/cartesian/Line.spec.tsx
  • src/polar/RadialBar.tsx
  • src/component/DefaultTooltipContent.tsx
  • src/state/selectors/funnelSelectors.ts
  • src/cartesian/Bar.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • src/polar/Radar.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/Treemap.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • src/state/selectors/touchSelectors.ts
  • src/cartesian/Funnel.tsx
  • src/chart/Sankey.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/cartesian/Line.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any strings or formatting choices in library code; users should provide localized strings as desired

Files:

  • src/state/touchEventsMiddleware.ts
  • src/polar/Pie.tsx
  • src/util/Constants.ts
  • src/cartesian/Area.tsx
  • src/chart/SunburstChart.tsx
  • src/polar/RadialBar.tsx
  • src/component/DefaultTooltipContent.tsx
  • src/state/selectors/funnelSelectors.ts
  • src/cartesian/Bar.tsx
  • src/polar/Radar.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/Treemap.tsx
  • src/state/selectors/touchSelectors.ts
  • src/cartesian/Funnel.tsx
  • src/chart/Sankey.tsx
  • src/cartesian/Line.tsx
test/component/**/*.spec.tsx

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use React Testing Library for testing component interactions and behavior upon rendering

Files:

  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
🧠 Learnings (15)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.
📚 Learning: 2025-11-23T13:30:10.395Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.

Applied to files:

  • test/cartesian/Bar.spec.tsx
  • test/helper/mockTouchingElement.ts
  • src/state/touchEventsMiddleware.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • src/polar/Pie.tsx
  • test/chart/Treemap.spec.tsx
  • src/util/Constants.ts
  • src/cartesian/Area.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • src/chart/SunburstChart.tsx
  • test/cartesian/Line.spec.tsx
  • src/polar/RadialBar.tsx
  • src/component/DefaultTooltipContent.tsx
  • src/state/selectors/funnelSelectors.ts
  • src/cartesian/Bar.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • src/polar/Radar.tsx
  • src/chart/Treemap.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • src/state/selectors/touchSelectors.ts
  • src/cartesian/Funnel.tsx
  • src/chart/Sankey.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/cartesian/Line.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : When testing tooltips on hover, use `vi.runOnlyPendingTimers()` after each `userEvent.hover()` call or use the `showTooltip` helper function from `tooltipTestHelpers.ts` to account for requestAnimationFrame delays

Applied to files:

  • test/cartesian/Bar.spec.tsx
  • test/helper/mockTouchingElement.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/component/Cursor.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • test/component/Tooltip/Tooltip.payload.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Verify the number of selector calls using the spy object from `createSelectorTestCase` to spot unnecessary re-renders and improve performance

Applied to files:

  • test/cartesian/Bar.spec.tsx
  • omnidoc/readProject.spec.ts
  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/component/Tooltip/Tooltip.formatter.spec.tsx
  • test/cartesian/Scatter.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/state/selectors/selectors.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • src/state/selectors/touchSelectors.ts
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/pieSelectors.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Use the `expectLastCalledWith` helper function instead of `expect(spy).toHaveBeenLastCalledWith(...)` for better typing and autocompletion

Applied to files:

  • test/cartesian/Bar.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-19T14:08:01.728Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.

Applied to files:

  • test/cartesian/Bar.spec.tsx
  • src/chart/SunburstChart.tsx
  • test/cartesian/Line.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Mock `getBoundingClientRect` in tests using the helper function provided in `test/helper/MockGetBoundingClientRect.ts`

Applied to files:

  • test/helper/mockTouchingElement.ts
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Prefer to use the `createSelectorTestCase` helper function when writing or modifying tests

Applied to files:

  • test/chart/ScatterChart.spec.tsx
  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to test/component/**/*.spec.tsx : Use React Testing Library for testing component interactions and behavior upon rendering

Applied to files:

  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/Treemap.spec.tsx
  • test/cartesian/Line.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/component/DefaultTooltipContent.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Call `vi.runOnlyPendingTimers()` to advance timers after renders when not using `createSelectorTestCase` helper, and avoid `vi.runAllTimers()` to prevent infinite loops

Applied to files:

  • test/component/Tooltip/defaultIndex.spec.tsx
  • test/chart/LineChart.spec.tsx
  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-12-06T03:36:59.377Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-06T03:36:59.377Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All imports from `recharts` must use the public API entry point; imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed

Applied to files:

  • test/chart/Treemap.spec.tsx
  • src/util/Constants.ts
  • src/chart/SunburstChart.tsx
  • test/polar/Pie.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-12-08T08:23:26.219Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.219Z
Learning: In the recharts codebase, `DataKey<any>` is an intentional exception to the "no any" rule while proper typing is being developed. This should not be flagged in reviews.

Applied to files:

  • src/util/Constants.ts
  • test/cartesian/Line.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Use `vi.useFakeTimers()` in all tests due to Redux autoBatchEnhancer dependency on timers and `requestAnimationFrame`

Applied to files:

  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to storybook/stories/**/*.stories.tsx : Use Storybook for smoke tests and add play functions with assertions for actual tests

Applied to files:

  • test/polar/Pie.spec.tsx
  • test/component/Tooltip/Tooltip.content.spec.tsx
  • test/cartesian/Area.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Use `userEvent.setup({ advanceTimers: vi.runOnlyPendingTimers })` or the `userEventSetup` helper function from `test/helper/userEventSetup.ts` when creating userEvent instances

Applied to files:

  • test/polar/Pie.spec.tsx
🧬 Code graph analysis (26)
test/helper/mockTouchingElement.ts (2)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
src/util/Constants.ts (2)
  • DATA_ITEM_INDEX_ATTRIBUTE_NAME (33-33)
  • DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME (39-39)
src/state/touchEventsMiddleware.ts (3)
src/util/Constants.ts (1)
  • DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME (39-39)
src/state/selectors/tooltipSelectors.ts (1)
  • selectAllGraphicalItemsSettings (110-119)
src/state/selectors/touchSelectors.ts (1)
  • selectTooltipCoordinate (12-44)
test/chart/ScatterChart.spec.tsx (2)
src/cartesian/Scatter.tsx (1)
  • Scatter (818-818)
src/index.ts (1)
  • Scatter (89-89)
test/component/Tooltip/defaultIndex.spec.tsx (3)
src/cartesian/Bar.tsx (1)
  • Bar (1085-1085)
src/cartesian/Line.tsx (1)
  • Line (873-873)
src/polar/Pie.tsx (1)
  • Pie (894-934)
src/polar/Pie.tsx (2)
src/index.ts (1)
  • PieSectorDataItem (61-61)
src/util/Constants.ts (1)
  • DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME (39-39)
src/cartesian/Area.tsx (1)
src/util/useUniqueId.ts (1)
  • WithIdRequired (33-35)
test/component/Tooltip/Tooltip.formatter.spec.tsx (1)
src/cartesian/Bar.tsx (1)
  • Bar (1085-1085)
test/component/Cursor.spec.tsx (1)
src/state/tooltipSlice.ts (1)
  • TooltipPayload (29-29)
src/chart/SunburstChart.tsx (2)
src/util/useUniqueId.ts (1)
  • WithIdRequired (33-35)
src/context/RegisterGraphicalItemId.tsx (1)
  • RegisterGraphicalItemId (18-21)
src/polar/RadialBar.tsx (2)
src/util/useUniqueId.ts (1)
  • WithIdRequired (33-35)
src/state/tooltipSlice.ts (1)
  • TooltipPayloadConfiguration (52-69)
src/state/selectors/funnelSelectors.ts (4)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
src/cartesian/Funnel.tsx (1)
  • FunnelTrapezoidItem (52-62)
src/state/selectors/dataSelectors.ts (1)
  • selectChartDataAndAlwaysIgnoreIndexes (24-35)
src/util/types.ts (1)
  • ChartOffsetInternal (643-651)
src/cartesian/Bar.tsx (1)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
test/chart/LineChart.spec.tsx (2)
src/cartesian/Line.tsx (1)
  • Line (873-873)
src/index.ts (1)
  • Line (81-81)
test/state/selectors/selectors.spec.tsx (3)
src/state/tooltipSlice.ts (2)
  • TooltipPayloadEntry (11-11)
  • TooltipPayloadConfiguration (52-69)
src/polar/Pie.tsx (1)
  • Pie (894-934)
src/index.ts (1)
  • Pie (56-56)
src/polar/Radar.tsx (1)
src/util/useUniqueId.ts (1)
  • WithIdRequired (33-35)
src/cartesian/Scatter.tsx (3)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
src/context/tooltipContext.tsx (3)
  • useMouseEnterItemDispatch (21-38)
  • useMouseLeaveItemDispatch (40-48)
  • useMouseClickItemDispatch (50-67)
src/util/Constants.ts (1)
  • DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME (39-39)
src/chart/Treemap.tsx (2)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
src/context/RegisterGraphicalItemId.tsx (1)
  • RegisterGraphicalItemId (18-21)
test/component/Tooltip/Tooltip.payload.spec.tsx (2)
src/cartesian/Line.tsx (1)
  • Line (873-873)
test/_data.ts (1)
  • PageData (4-11)
test/polar/Pie.spec.tsx (3)
src/util/Constants.ts (2)
  • DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME (39-39)
  • DATA_ITEM_INDEX_ATTRIBUTE_NAME (33-33)
src/polar/Pie.tsx (2)
  • PieSectorDataItem (157-161)
  • Pie (894-934)
test/helper/mockTouchingElement.ts (1)
  • mockTouchingElement (18-23)
src/state/selectors/touchSelectors.ts (5)
src/state/tooltipSlice.ts (2)
  • TooltipPayloadConfiguration (52-69)
  • TooltipPayloadSearcher (45-50)
src/state/selectors/selectTooltipState.ts (1)
  • selectTooltipState (4-4)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
src/util/types.ts (1)
  • Coordinate (88-91)
src/state/selectors/selectTooltipPayloadSearcher.ts (1)
  • selectTooltipPayloadSearcher (4-5)
src/chart/Sankey.tsx (4)
src/util/useUniqueId.ts (1)
  • WithIdRequired (33-35)
src/state/RechartsStoreProvider.tsx (1)
  • RechartsStoreProvider (15-53)
src/context/chartLayoutContext.tsx (2)
  • ReportChartSize (165-208)
  • ReportChartMargin (210-216)
src/context/RegisterGraphicalItemId.tsx (1)
  • RegisterGraphicalItemId (18-21)
test/component/Tooltip/itemSorter.spec.tsx (8)
src/cartesian/Area.tsx (1)
  • Area (1074-1074)
src/cartesian/Bar.tsx (1)
  • Bar (1085-1085)
src/cartesian/Line.tsx (1)
  • Line (873-873)
src/cartesian/Scatter.tsx (1)
  • Scatter (818-818)
src/polar/Pie.tsx (1)
  • Pie (894-934)
test/_data.ts (1)
  • PageData (4-11)
src/polar/Radar.tsx (1)
  • Radar (571-602)
src/polar/RadialBar.tsx (1)
  • RadialBar (646-671)
src/cartesian/Line.tsx (1)
src/state/graphicalItemsSlice.ts (1)
  • GraphicalItemId (19-19)
test/component/Tooltip/Tooltip.visibility.spec.tsx (4)
src/polar/Pie.tsx (1)
  • Pie (894-934)
src/polar/Radar.tsx (1)
  • Radar (571-602)
src/polar/RadialBar.tsx (1)
  • RadialBar (646-671)
test/helper/mockTouchingElement.ts (1)
  • mockTouchingElement (18-23)
test/component/Tooltip/Tooltip.content.spec.tsx (2)
src/component/Tooltip.tsx (1)
  • TooltipContentProps (42-49)
src/cartesian/Area.tsx (1)
  • Area (1074-1074)
test/cartesian/Area.spec.tsx (2)
src/state/tooltipSlice.ts (1)
  • TooltipPayloadConfiguration (52-69)
test/helper/expectLastCalledWith.ts (1)
  • expectLastCalledWith (14-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (67)
test/component/Cursor.spec.tsx (2)

11-11: LGTM: Import adds type safety to tests.

The import of TooltipPayload from the internal tooltipSlice module is appropriate for this test file and enables explicit typing of the payload variable in the tests below.


167-167: LGTM: Type annotation and graphicalItemId addition align with PR objectives.

The explicit TooltipPayload type annotation adds type safety, and the graphicalItemId property correctly implements the PR's goal of wiring graphical item IDs into tooltip payloads.

src/polar/RadialBar.tsx (1)

365-399: Tooltip payload wiring for graphicalItemId looks correct and consistently typed.
WithIdRequired<PropsWithDefaults> + settings.graphicalItemId: id + passing id={props.id} ensures the registered id is available downstream (selectors/payload generation).

Also applies to: 464-499

test/component/DefaultTooltipContent.spec.tsx (1)

3-7: Test updates correctly reflect the extended payload shape (graphicalItemId) and use the exported prop type.

Also applies to: 38-53

src/polar/Radar.tsx (1)

158-197: Radar tooltip entry settings now correctly include graphicalItemId sourced from the registered id.

Also applies to: 571-599

test/cartesian/Scatter.spec.tsx (1)

579-623: Tooltip payload assertions appropriately validate the presence of graphicalItemId without overfitting to an exact generated value.

test/cartesian/Line.spec.tsx (1)

457-481: Line tooltip payload test correctly asserts graphicalItemId presence using a stable pattern.

omnidoc/readProject.spec.ts (1)

79-86: Snapshot update for Funnel reflected public properties looks consistent with a narrowed runtime surface.

test/chart/Treemap.spec.tsx (1)

373-476: Treemap event payload tests now correctly assert the presence of the generated id while keeping existing behavioral checks intact.

Also applies to: 517-620, 644-742

test/cartesian/Bar.spec.tsx (1)

1587-1722: Payload graphicalItemId assertions are good; please sanity-check whether interaction state should also carry it.
Right now the test expects itemInteraction.hover.graphicalItemId to stay undefined even though payload entries have ids—if that’s intentional (scope-limited to payload only), all good; otherwise this is an easy place to thread it through.

src/util/Constants.ts (1)

28-40: Constant rename/addition looks consistent; consider tightening the doc comment
The new DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME and its usage intent are clear. Minor: the comment says “Unlike dataKey, or name, it is always unique” — might be worth explicitly saying “graphical item id” is unique per rendered item (and not per data point).

test/component/Tooltip/Tooltip.formatter.spec.tsx (1)

34-36: Good test stabilization: explicit Bar ids + graphicalItemId assertions
Adding id="bar-with-function" / id="bar-pv" makes the new graphicalItemId expectations deterministic and aligns with the PR objective.

Also applies to: 57-58, 77-78, 113-115, 150-151, 170-171

test/chart/LineChart.spec.tsx (1)

827-860: LGTM: tooltip integration test covers graphicalItemId end-to-end
Explicit id="line-y" plus the selector assertion should catch regressions in the tooltip payload pipeline.

src/polar/Pie.tsx (5)

43-44: Import/update to use graphical item id attribute looks consistent
No concerns with adding DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME alongside the index attribute for touch picking.


325-360: LGTM: Pie tooltip entry settings now carry graphicalItemId
Threading id into SetPieTooltipEntrySettings and writing it into tooltipEntrySettings.settings.graphicalItemId matches the intended pipeline.


551-573: Correct DOM wiring: sectors expose both index + graphical item id
Adding [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: id should make item tooltips resolvable even when dataKey/name are ambiguous.


646-655: Good: sector tooltip payload includes graphicalItemId
This ensures consumers can disambiguate tooltip entries for identical dataKeys across multiple pies.


871-887: Good propagation: PieImpl passes the resolved id into tooltip settings
id={id} on SetPieTooltipEntrySettings keeps the id consistent between state and payload.

test/state/selectors/pieSelectors.spec.tsx (1)

74-88: Solid coverage: selector outputs now assert graphicalItemId consistently
The expectations validate graphicalItemId across initial render, after interaction (dataKey change), and with custom data props.

Also applies to: 122-136, 170-184, 218-232, 266-280, 314-328, 362-376, 423-437, 471-485, 519-533, 567-581, 615-629, 663-677, 711-725, 796-810, 843-857

src/cartesian/Bar.tsx (3)

87-88: Good: internal Bar id typed as GraphicalItemId
This aligns the Bar pipeline with the store’s id type and avoids accidental mixing with unrelated string ids.

Also applies to: 352-357


382-416: LGTM: Bar tooltip settings now include graphicalItemId
Setting tooltipEntrySettings.settings.graphicalItemId = id is the key wiring needed for the tooltip payload additions.


1042-1076: Good propagation: resolved id is passed into tooltip settings and Bar impl
RegisterGraphicalItemIdSetBarTooltipEntrySettings id={id} keeps tooltip identity stable and testable.

test/component/Tooltip/Tooltip.content.spec.tsx (1)

24-32: Good coverage: deterministic id → asserted graphicalItemId in payload.
This test does a nice job pinning the new linkage end-to-end for Area.

Also applies to: 77-182

test/chart/ScatterChart.spec.tsx (1)

1436-1456: LGTM: Scatter tooltip payload/config assertions now verify graphicalItemId.

Also applies to: 1511-1520, 2267-2274, 2442-2488

test/state/selectors/selectors.spec.tsx (2)

54-100: LGTM: selector expectations now propagate graphicalItemId end-to-end.

Also applies to: 261-509, 1246-1326


1-3: Tests: confirm vi.useFakeTimers() is applied for this file (global setup or add here).
Guidelines require fake timers due to Redux batching + rAF timing. If not globally enabled, add a beforeEach(() => vi.useFakeTimers()).

Also applies to: 694-699

src/cartesian/Scatter.tsx (2)

264-307: LGTM: Scatter tooltip settings now include graphicalItemId derived from id.

Also applies to: 758-768


439-448: Nice: DOM attribute is now based on graphicalItemId instead of dataKey.
This aligns touch/hover targeting with the new identity model.

src/chart/SunburstChart.tsx (2)

49-94: LGTM: id?: string added to Sunburst public props for deterministic identity.


129-163: Good: RegisterGraphicalItemId now drives settings.graphicalItemId for Sunburst tooltips.

Also applies to: 202-225, 365-380

test/component/Tooltip/Tooltip.payload.spec.tsx (2)

165-173: LGTM: tests now assert graphicalItemId for data-on-item LineChart payloads/configs.

Also applies to: 467-957, 969-1136, 1138-1212


442-446: Tests: confirm fake timers are enabled (global setup or add here).
If not already handled by createSelectorTestCase / test setup, add vi.useFakeTimers() per guidelines.

src/cartesian/Line.tsx (2)

221-256: Good: tooltip entry settings now carry graphicalItemId.
Adding graphicalItemId: id in TooltipPayloadConfiguration.settings is the right place to attach this identifier for downstream selectors/searchers.


835-869: Good: uses RegisterGraphicalItemId output to populate tooltip settings.
This ensures the tooltip gets the same id that’s used for state/graphical-item registration (and not the optional external prop directly).

src/state/selectors/funnelSelectors.ts (2)

10-23: Good: ResolvedFunnelSettings.id makes the identity explicit and typed.
This aligns funnel trapezoid computation with the new graphical-item-id plumbing.


30-83: Good: selector forwards graphicalItemId; verify that graphical item IDs are guaranteed unique per chart instance.

The implementation relies on IDs being unique for tooltip/event disambiguation—specifically, touchEventsMiddleware uses .find(item => item.id === graphicalItemId) which returns only the first match. If duplicate IDs exist, the wrong item could be selected. While the codebase documents that graphicalItemId should be unique (see src/state/graphicalItemsSlice.ts lines 15–26), the reducer does not validate uniqueness when items are added or updated. Confirm that user-provided or auto-generated IDs are guaranteed to be unique per chart instance, or add validation to prevent regressions.

test/component/Tooltip/defaultIndex.spec.tsx (3)

14-76: Good: BarChart expectations now assert graphicalItemId in tooltip payload (including hover update).
Nice use of showTooltip + expectLastCalledWith for stable assertions.


85-120: Good: LineChart (multi XAxes) payload now carries graphicalItemId and remains deterministic.


133-209: Good: PieChart payload assertions updated for graphicalItemId, including hover change.

src/cartesian/Area.tsx (1)

289-324: Good: graphicalItemId is added to Area tooltip entry settings, and id is enforced for the internal call.

src/state/selectors/touchSelectors.ts (1)

4-44: The selector implementation is correct and the concern in this review comment is unfounded.

Analysis: The code at line 31 properly matches tooltip configurations by settings.graphicalItemId. The graphicalItemId field is present in TooltipEntrySettings because it's part of the Payload interface (defined in DefaultTooltipContent.tsx). More importantly, the id prop is always guaranteed to be a non-null string because all graphical item components (Line, Bar, Pie, etc.) pass their id through the useUniqueId hook before calling SetTooltipEntrySettings. The hook generates a unique ID if none is provided, ensuring the value is never undefined.

Therefore: All tooltip configurations will reliably have graphicalItemId set, the selector matching will work as intended, and there is no risk of silent failures returning undefined. No backwards-compatibility fallback is needed.

test/polar/Pie.spec.tsx (5)

1-56: Import and setup changes look correct.

The updated imports properly bring in Mock type and the renamed DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME constant. The test file correctly imports from internal source paths which is acceptable for test files.


334-416: Test assertions properly validate the new graphicalItemId in activeShape payload.

The Mock<(props: PieSectorDataItem) => ReactNode> typing and @ts-expect-error comments indicate known typing gaps that should be addressed separately. The expectLastCalledWith helper is correctly used per coding guidelines, and the graphicalItemId: 'pie-y' assertion properly matches the id="pie-y" prop on the Pie component.


786-843: Tooltip integration tests correctly updated with graphicalItemId.

The test case properly:

  • Adds id="cy-pie" to the Pie component
  • Updates mockTouchingElement calls to use the new signature with graphicalItemId
  • Verifies graphicalItemId: 'cy-pie' in tooltip state assertions

1863-1938: Event handler tests correctly verify graphicalItemId in tooltip payload.

The onClick test properly:

  • Adds id="pie-uv" to the Pie component
  • Verifies graphicalItemId: 'pie-uv' in the tooltipPayload array
  • Uses expectLastCalledWith helper as per coding guidelines

1086-1092: Verify if setActiveMouseOverItemIndex from the touch middleware correctly populates graphicalItemId in the hover state.

The implementation in touchEventsMiddleware.ts (lines 56-67) does extract graphicalItemId from the element's DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME attribute via elementFromPoint. It then dispatches setActiveMouseOverItemIndex with this value.

However, the test expects graphicalItemId: undefined in the hover state. This inconsistency suggests one of the following:

  1. The setActiveMouseOverItemIndex action is not correctly passing activeGraphicalItemId to the reducer, despite extracting it in the middleware
  2. A different code path handles touch events that doesn't use setActiveMouseOverItemIndex
  3. The test's mock setup with mockTouchingElement('2', 'cy-pie') is not properly simulating the actual touch event flow

The mouse hover equivalent works correctly because it sets graphicalItemId: 'cy-pie' (line 842), suggesting the inconsistency is real and needs investigation into which step of the touch event pipeline is dropping the graphicalItemId.

src/chart/Sankey.tsx (4)

31-32: Imports correctly added for ID registration pattern.

The WithIdRequired and RegisterGraphicalItemId imports align with the pattern used across other chart components in this PR.


533-563: SetSankeyTooltipEntrySettings correctly wires graphicalItemId into tooltip configuration.

The component properly:

  • Accepts id in its props via the updated Pick type
  • Includes graphicalItemId: id in the tooltip settings

This matches the pattern used in other components like SetFunnelTooltipEntrySettings.


951-955: Internal type definitions correctly establish ID-required contract.

The InternalSankeyProps type properly uses WithIdRequired<PropsWithResolvedDefaults> to ensure the internal implementation always receives a resolved ID, while the public Props type allows an optional ID.


1096-1154: Sankey component correctly implements the RegisterGraphicalItemId pattern.

The implementation:

  • Extracts externalId from resolved props
  • Wraps the content with RegisterGraphicalItemId using type "sankey"
  • Passes the resolved id to both SetSankeyTooltipEntrySettings and SankeyImpl

This follows the established pattern from other components in this PR.

src/cartesian/Funnel.tsx (7)

48-50: Imports correctly added for graphical item ID wiring.

The imports for GraphicalItemId, RegisterGraphicalItemId, and WithIdRequired align with the pattern established across other chart components.


67-70: InternalFunnelProps correctly defines id as required.

Using GraphicalItemId type for id ensures type consistency across the codebase.


134-172: SetFunnelTooltipEntrySettings correctly integrates graphicalItemId.

The component properly:

  • Accepts id via the updated Pick type (line 149)
  • Includes graphicalItemId: id in tooltip settings (line 167)

This matches the pattern in other components.


224-232: Destructuring id from trapezoidProps prevents passing it to DOM elements.

This is a good practice to avoid React warnings about unknown DOM attributes. The id is destructured but not used here since it's not needed in the individual trapezoid rendering context.


476-537: computeFunnelTrapezoids correctly adds graphicalItemId to tooltip payload.

The function properly:

  • Accepts graphicalItemId parameter (line 485)
  • Includes it in the TooltipPayload array (line 536)

This ensures the tooltip payload carries the graphical item identifier for each funnel segment.


592-601: Funnel component correctly implements RegisterGraphicalItemId pattern.

The implementation:

  • Extracts externalId from resolved props and spreads remaining props
  • Wraps content with RegisterGraphicalItemId using type "funnel"
  • Passes the resolved id to FunnelImpl

This is consistent with the pattern used in Sankey and other chart components.


381-427: FunnelImpl correctly uses the id in funnelSettings for selector consumption.

The id is properly:

  • Included in the funnelSettings object (line 413)
  • Added to the dependency array of useMemo (line 425)

This ensures the selector receives the graphical item ID for proper tooltip coordination.

test/component/Tooltip/Tooltip.visibility.spec.tsx (4)

4-35: Import change looks fine; ensure DefaultZIndexes is part of the intended test surface.


109-307: Good: explicit id props make graphicalItemId assertions deterministic.


441-448: Touch-mocking updated correctly for graphicalItemId.


767-801: Assertions updated consistently to include id/graphicalItemId.

Also applies to: 1060-1232

src/chart/Treemap.tsx (2)

42-43: LGTM: Treemap now supports an external id prop, consistent with other items.

Also applies to: 401-403


547-577: LGTM: graphicalItemId is now included in Treemap tooltip entry settings.

Also applies to: 919-926

test/component/Tooltip/itemSorter.spec.tsx (2)

51-62: Nice: explicit ids on composed items make itemSorter tests stable and exercise graphicalItemId.


78-436: Assertions updated thoroughly to include graphicalItemId across chart types.

Also applies to: 635-740, 914-959, 967-1276, 1278-1920, 1929-2314, 2321-2706

test/cartesian/Area.spec.tsx (2)

4-4: Import updates look consistent with the new tooltip payload shape.

Also applies to: 24-24


820-887: Good upgrade: strongly typed tooltipSpy + graphicalItemId assertion improves coverage.

Comment on lines +1 to +2
import React, { ReactNode } from 'react';
import { beforeEach, describe, expect, it, Mock } from 'vitest';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Read the spec file to see vi usage
cat -n test/component/Tooltip/Tooltip.content.spec.tsx | head -50

Repository: recharts/recharts

Length of output: 2146


🏁 Script executed:

# Check for Vitest configuration
fd -e 'config.ts' -e 'config.js' | grep -E '(vitest|vite)' | head -20

Repository: recharts/recharts

Length of output: 79


🏁 Script executed:

# Look for vitest config in the repo root or common locations
find . -maxdepth 2 -type f \( -name 'vitest.config.*' -o -name 'vite.config.*' \) 2>/dev/null

Repository: recharts/recharts

Length of output: 101


🏁 Script executed:

cat -n ./vitest.config.mts

Repository: recharts/recharts

Length of output: 3280


Import vi from vitest for clarity and IDE support.

Line 17 uses vi.fn() but vi is not imported. While Vitest's globals: true configuration makes this work at runtime, explicit imports improve code clarity and enable better IDE autocompletion.

-import { beforeEach, describe, expect, it, Mock } from 'vitest';
+import { beforeEach, describe, expect, it, Mock, vi } from 'vitest';

Also applies to: 16-18

🤖 Prompt for AI Agents
In test/component/Tooltip/Tooltip.content.spec.tsx lines 1-2, the test uses
vi.fn() later but vi is not explicitly imported; update the imports to include
vi from 'vitest' (e.g., import { beforeEach, describe, expect, it, vi, Mock }
from 'vitest' or add a separate import for vi) so the symbol is explicit for
IDEs and type support.

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.70%. Comparing base (b8f09a4) to head (adfbb6e).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6765   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files         515      515           
  Lines       43011    43082   +71     
  Branches     5018     5021    +3     
=======================================
+ Hits        40302    40370   +68     
- Misses       2703     2706    +3     
  Partials        6        6           

☔ 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.

@github-actions
Copy link
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@codecov
Copy link

codecov bot commented Dec 12, 2025

Bundle Report

Changes will increase total bundle size by 2.04kB (0.08%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.17MB 684 bytes (0.06%) ⬆️
recharts/bundle-es6 1.01MB 672 bytes (0.07%) ⬆️
recharts/bundle-umd 521.58kB 687 bytes (0.13%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
chart/Sankey.js 344 bytes 28.83kB 1.21%
chart/Treemap.js 302 bytes 27.07kB 1.13%
cartesian/Area.js 47 bytes 26.57kB 0.18%
cartesian/Bar.js 47 bytes 25.71kB 0.18%
cartesian/Line.js 47 bytes 24.6kB 0.19%
polar/Pie.js 92 bytes 24.31kB 0.38%
cartesian/Scatter.js 32 bytes 22.42kB 0.14%
polar/RadialBar.js 53 bytes 19.26kB 0.28%
cartesian/Funnel.js 305 bytes 16.82kB 1.85%
polar/Radar.js 53 bytes 15.93kB 0.33%
chart/SunburstChart.js 314 bytes 11.31kB 2.85%
state/touchEventsMiddleware.js 352 bytes 2.95kB 13.56% ⚠️
state/selectors/funnelSelectors.js 46 bytes 2.79kB 1.67%
state/selectors/touchSelectors.js 30 bytes 1.16kB 2.67%
util/Constants.js -1.39kB 906 bytes -60.57%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 687 bytes 521.58kB 0.13%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
chart/Sankey.js 369 bytes 30.55kB 1.22%
chart/Treemap.js 327 bytes 28.75kB 1.15%
cartesian/Area.js 47 bytes 28.44kB 0.17%
cartesian/Bar.js 47 bytes 27.42kB 0.17%
cartesian/Line.js 47 bytes 26.21kB 0.18%
polar/Pie.js 82 bytes 26.05kB 0.32%
cartesian/Scatter.js 22 bytes 24.05kB 0.09%
polar/RadialBar.js 53 bytes 20.72kB 0.26%
cartesian/Funnel.js 244 bytes 18.29kB 1.35%
polar/Radar.js 53 bytes 17.4kB 0.31%
chart/SunburstChart.js 339 bytes 12.61kB 2.76%
state/touchEventsMiddleware.js 350 bytes 3.2kB 12.27% ⚠️
state/selectors/funnelSelectors.js 46 bytes 2.96kB 1.58%
state/selectors/touchSelectors.js 30 bytes 1.38kB 2.23%
util/Constants.js -1.37kB 1.26kB -52.13%

maxRadius: 275.77164466275354,
midAngle: 38.579169175195666,
middleRadius: 100,
// @ts-expect-error somehow name is a number even though type says string
Copy link
Member

Choose a reason for hiding this comment

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

hm sus

@ckifer
Copy link
Member

ckifer commented Dec 12, 2025

thanks!

@ckifer ckifer merged commit d85fdde into main Dec 12, 2025
39 of 40 checks passed
@ckifer ckifer deleted the graphical-item-id branch December 12, 2025 06:01
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.

2 participants