Skip to content

Add new axis type: "auto", fix default angle and radius axis#6823

Merged
ckifer merged 6 commits intomainfrom
axis-type-auto
Dec 26, 2025
Merged

Add new axis type: "auto", fix default angle and radius axis#6823
ckifer merged 6 commits intomainfrom
axis-type-auto

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Dec 25, 2025

Description

I have added new axis.type: "auto". This one sets the type to "category" for categorical axes, and "number" for numeric axis.

Then I made the new "auto" the default for PolarAngleAxis and PolarRadiusAxis. These two already had some smart-ish settings, where they attempted to set the type by default, since 2.x or before. Too bad that the smarts were not thorough, and the default axes didn't work. Now they do! I consider this a bugfix, because the default axes were completely broken before.

XAxis and YAxis too have type="auto" available but I left their defaults. Vertical charts are viable (albeit a bit confusing) and so I think new defaults here would be a breaking change. Let's do that in 4.0?

Also I added a little domain shape guard and these two together allowed me to get rid of checkDomainOfScale so now we're not mutating the scale once created which is nice.

Related Issue

Weirdly enough I couldn't find anyone who complained about this but you can see the improvement from the VR test.

Contributes a little to #6645

Motivation and Context

I expect that chart with implicit axes (i.e. without "PolarAngleAxis" in JSX) and chart with default axes (i.e. with "") should be the same chart, with ticks and axisLine added.

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

  • New Features

    • Axes gain an "auto" mode that infers number/category from chart layout; polar layouts expose layout-aware hooks and utilities.
  • Improvements

    • Safer domain checking and more consistent axis-type evaluation; defaults for polar axes changed to "auto"; corrected axis range orientation across charts.
  • Documentation

    • API docs and story controls expanded to describe "auto" behavior and scale/domain guidance.
  • Tests

    • Added and updated tests for auto inference, polar behavior, domain checks, and adjusted scale expectations.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

Walkthrough

Adds an auto axis input mode and runtime axis-type inference based on chart layout; introduces utilities and selectors to validate/normalize axis domains; updates cartesian and polar axis components to compute/memoize evaluated types and dispatch evaluated settings; adjusts types, docs, stories, and many tests.

Changes

Cohort / File(s) Summary
Types & core axis types
src/util/types.ts
Add AxisDomainTypeInput (`'number'
Axis type resolver util
src/util/getAxisTypeBasedOnLayout.ts
New exported function getAxisTypeBasedOnLayout(layout, axisType, axisDomainType) that resolves 'auto' to `'number'
Domain checker combiner
src/state/selectors/combiners/combineCheckedDomain.ts
New combiner to validate/normalize numeric domains for linear scales, returning a safe NumberDomain/CategoricalDomain or undefined.
Cartesian axis components
src/cartesian/XAxis.tsx, src/cartesian/YAxis.tsx
Props accept AxisDomainTypeInput; compute evaluated type via layout hook + resolver; memoize settings with useMemo; update Set*Settings signatures and guarded dispatch (add/replace only when evaluated settings exist).
Polar axis components & defaults
src/polar/PolarAngleAxis.tsx, src/polar/PolarRadiusAxis.tsx, src/polar/defaultPolarAngleAxisProps.tsx, src/polar/defaultPolarRadiusAxisProps.tsx
Switch type to AxisDomainTypeInput, change defaults to 'auto', evaluate type via usePolarChartLayout + resolver, memoize and guard dispatch when evaluation yields undefined.
Chart layout context (polar)
src/context/chartLayoutContext.tsx
Add selectPolarChartLayout and usePolarChartLayout to expose polar layout for runtime evaluation.
Selectors — axis, polar, tooltip
src/state/selectors/axisSelectors.ts, src/state/selectors/polarAxisSelectors.ts, src/state/selectors/polarScaleSelectors.ts, src/state/selectors/polarSelectors.ts, src/state/selectors/tooltipSelectors.ts
Add selectCheckedAxisDomain / selectPolarAxisCheckedDomain using combineCheckedDomain; rewire selectors to use checked domains and layout-based type resolution; simplify inputs for some real-scale selectors.
Axis state shape
src/state/cartesianAxisSlice.ts
Change BaseCartesianAxis.type to EvaluatedAxisDomainType (axis type resolved before persisting state).
Scale & chart utilities
src/util/scale/RechartsScale.ts, src/util/ChartUtils.ts
Derive fixed [min,max] range from d3 range; remove checkDomainOfScale and its mutation path.
Snapshots / build outputs
scripts/snapshots/es6Files.txt, scripts/snapshots/libFiles.txt, scripts/snapshots/typesFiles.txt
Add entries for getAxisTypeBasedOnLayout and combineCheckedDomain across ES6/lib/types snapshots.
Tests
test/** (many files)
Add axis-type tests; update many expectations (range direction flips, domain/type changes); remove tests for deleted checkDomainOfScale; add null guard in test helper; update tests to use AxisDomainTypeInput.
Docs, stories, examples
www/src/docs/api/*, storybook/stories/API/polar/*, www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
Expand API docs for type/scale to include auto and examples; update story defaults to 'auto'; add <Tooltip /> to example.

Sequence Diagram(s)

sequenceDiagram
    participant Comp as Axis Component (XAxis/YAxis/PolarAxis)
    participant Layout as Chart Layout Context
    participant Eval as getAxisTypeBasedOnLayout
    participant Memo as memoization (useMemo)
    participant State as Redux Store

    Comp->>Layout: request layout (use*ChartLayout)
    Layout-->>Comp: layout (or undefined)

    Comp->>Eval: getAxisTypeBasedOnLayout(layout, axisKind, typeProp)
    alt typeProp != 'auto'
        Eval-->>Comp: explicit type
    else
        Eval->>Layout: isCategoricalAxis(layout, axisKind)?
        Layout-->>Eval: true / false
        Eval-->>Comp: 'category' or 'number'
    end

    Comp->>Memo: build memoized settings (includes evaluated type)
    Memo-->>Comp: settings | undefined

    alt settings defined
        Comp->>State: dispatch addAxis or replaceAxis(settings)
        State-->>Comp: persisted axis (with EvaluatedAxisDomainType)
    else
        Comp-->>State: no-op (skip dispatch)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

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 27.27% 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 summarizes the main change: adding a new 'auto' axis type and fixing default angle and radius axis behavior. It is specific and directly related to the primary changeset focus.
Description check ✅ Passed The PR description is comprehensive and covers all required template sections: detailed explanation of changes, related issue reference, motivation/context, testing approach, and types of changes with checklist completed.
✨ 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 axis-type-auto

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: 8

Caution

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

⚠️ Outside diff range comments (1)
src/polar/PolarRadiusAxis.tsx (1)

210-218: Missing dependency array in useEffect causes repeated dispatches.

The useEffect on line 210 has no dependency array, which means it runs after every render. This will dispatch addRadiusAxis on every render cycle, potentially causing performance issues and unnecessary Redux state updates.

Compare this to the XAxis.tsx implementation which uses useLayoutEffect with proper dependencies [settings, dispatch] and tracks previous settings via a ref to avoid redundant dispatches.

🔎 Suggested fix - align with XAxis pattern
+  const prevSettingsRef = useRef<RadiusAxisSettings | null>(null);
+
-  useEffect(() => {
+  useLayoutEffect(() => {
     if (settings == null) {
-      return noop;
+      return;
     }
-    dispatch(addRadiusAxis(settings));
-    return () => {
-      dispatch(removeRadiusAxis(settings));
-    };
-  });
+    if (prevSettingsRef.current === null) {
+      dispatch(addRadiusAxis(settings));
+    } else if (prevSettingsRef.current !== settings) {
+      // Consider adding replaceRadiusAxis action similar to XAxis
+      dispatch(removeRadiusAxis(prevSettingsRef.current));
+      dispatch(addRadiusAxis(settings));
+    }
+    prevSettingsRef.current = settings;
+  }, [settings, dispatch]);
+
+  useLayoutEffect(() => {
+    return () => {
+      if (prevSettingsRef.current) {
+        dispatch(removeRadiusAxis(prevSettingsRef.current));
+        prevSettingsRef.current = null;
+      }
+    };
+  }, [dispatch]);
🧹 Nitpick comments (5)
test/component/Tooltip/itemSorter.spec.tsx (1)

1283-1937: RadialBar tooltip itemSorter expectations correctly updated for new polar axis wiring

Swapping the axis bindings to <PolarAngleAxis dataKey="uv" /> and <PolarRadiusAxis dataKey="name" /> and updating the corresponding tooltip payload and geometry expectations brings these tests in line with the new polar axis defaults (type="auto" and layout‑based evaluation). The new domains, radii, and item orderings are internally consistent with the rest of the tooltip and polar tests.

If you see these tests getting fragile in future refactors, you might consider narrowing them to assert just the ordering and key fields instead of full nested geometry, but that’s not required for this PR.

test/cartesian/XAxis/XAxis.type.spec.tsx (1)

1-131: Well-structured test suite following project conventions.

The tests properly use:

  • createSelectorTestCase helper for test setup
  • expectLastCalledWith for assertions
  • Internal imports (allowed in test files per learnings)

The comment on lines 33-36 documenting the "unfortunate behavior" is helpful for understanding the backward compatibility constraint.

Consider adding selector call count assertions to verify no unnecessary re-renders occur, as recommended by the coding guidelines:

// Example addition to each test:
expect(spy).toHaveBeenCalledTimes(1);
src/cartesian/YAxis.tsx (1)

168-183: Optional: stabilize SetYAxisSettings memoization to avoid extra replace actions.

The layout-based type evaluation and early-return when evaluatedType is null look correct. However, because restProps is spread from props and included directly in the useMemo dependency array, settings will be a new object on every render, which in turn makes prevSettingsRef.current !== settings and causes replaceYAxis to dispatch on every render even when no props changed.

If you want to reduce Redux churn, consider deriving settings either:

  • From a more stable dependency list (individual primitive props instead of the restProps object), or
  • By memoizing the props passed into SetYAxisSettings at the call site, so referential equality can be reused across renders.

Not correctness‑critical, but it would tighten up performance on heavily re-rendering charts.

src/cartesian/XAxis.tsx (1)

162-170: Unstable memoization dependency on restProps.

The restProps object is created fresh on every render via destructuring on line 159, causing the useMemo to recompute on every render. Consider memoizing based on props directly or use a stable reference.

🔎 Suggested fix
 function SetXAxisSettings(props: Omit<XAxisSettings, 'type'> & { type: AxisDomainTypeInput }): ReactNode {
   const dispatch = useAppDispatch();
   const prevSettingsRef = useRef<XAxisSettings | null>(null);
   const layout = useCartesianChartLayout();
   const { type: typeFromProps, ...restProps } = props;
   const evaluatedType: EvaluatedAxisDomainType | undefined = getAxisTypeBasedOnLayout(layout, 'xAxis', typeFromProps);

   const settings: XAxisSettings | undefined = useMemo(() => {
     if (evaluatedType == null) {
       return undefined;
     }
     return {
       ...restProps,
       type: evaluatedType,
     };
-  }, [restProps, evaluatedType]);
+  }, [props, evaluatedType]);

Note: Since restProps is derived from props minus type, and evaluatedType already captures the type change, using props as the dependency is more stable while still reacting to all relevant changes.

src/polar/PolarRadiusAxis.tsx (1)

198-209: Unstable memoization: props object changes on every render.

Similar to the XAxis issue, using props as a dependency will cause useMemo to recompute on every render since props is a new object each time. Consider destructuring the specific properties needed or using a different memoization strategy.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d52345f and f1edfe0.

⛔ Files ignored due to path filters (6)
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-webkit-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-webkit-linux.png is excluded by !**/*.png
📒 Files selected for processing (48)
  • scripts/snapshots/es6Files.txt
  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/context/chartLayoutContext.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/polar/defaultPolarAngleAxisProps.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/state/cartesianAxisSlice.ts
  • src/state/selectors/axisSelectors.ts
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • src/state/selectors/polarAxisSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/tooltipSelectors.ts
  • src/util/ChartUtils.ts
  • src/util/getAxisTypeBasedOnLayout.ts
  • src/util/scale/RechartsScale.ts
  • src/util/types.ts
  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/helper/expectScale.ts
  • test/polar/PolarAngleAxis.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/state/selectors/selectBaseAxis.spec.tsx
  • test/util/ChartUtils/checkDomainOfScale.spec.ts
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • www/src/docs/api/ZAxisAPI.tsx
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
💤 Files with no reviewable changes (2)
  • src/util/ChartUtils.ts
  • test/util/ChartUtils/checkDomainOfScale.spec.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{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:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • test/state/selectors/selectBaseAxis.spec.tsx
  • src/util/getAxisTypeBasedOnLayout.ts
  • src/polar/defaultPolarAngleAxisProps.tsx
  • test/chart/RadarChart.spec.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • test/polar/PolarGrid.spec.tsx
  • src/util/types.ts
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/helper/expectScale.ts
  • www/src/docs/api/ZAxisAPI.tsx
  • src/state/cartesianAxisSlice.ts
  • test/polar/Radar.spec.tsx
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • src/state/selectors/tooltipSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/cartesian/XAxis.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • src/polar/PolarRadiusAxis.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • test/state/selectors/radarSelectors.spec.tsx
storybook/stories/**/*.stories.tsx

📄 CodeRabbit inference engine (CONTRIBUTING.md)

storybook/stories/**/*.stories.tsx: Use Storybook for smoke tests and add play functions with assertions for actual tests
Update Storybook stories when APIs have been changed to ensure they work as expected

Files:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • test/state/selectors/selectBaseAxis.spec.tsx
  • src/util/getAxisTypeBasedOnLayout.ts
  • src/polar/defaultPolarAngleAxisProps.tsx
  • test/chart/RadarChart.spec.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • test/polar/PolarGrid.spec.tsx
  • src/util/types.ts
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/helper/expectScale.ts
  • www/src/docs/api/ZAxisAPI.tsx
  • src/state/cartesianAxisSlice.ts
  • test/polar/Radar.spec.tsx
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • src/state/selectors/tooltipSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/cartesian/XAxis.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • src/polar/PolarRadiusAxis.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • test/state/selectors/radarSelectors.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:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • test/state/selectors/selectBaseAxis.spec.tsx
  • src/util/getAxisTypeBasedOnLayout.ts
  • src/polar/defaultPolarAngleAxisProps.tsx
  • test/chart/RadarChart.spec.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • test/polar/PolarGrid.spec.tsx
  • src/util/types.ts
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/helper/expectScale.ts
  • www/src/docs/api/ZAxisAPI.tsx
  • src/state/cartesianAxisSlice.ts
  • test/polar/Radar.spec.tsx
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • src/state/selectors/tooltipSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/cartesian/XAxis.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • src/polar/PolarRadiusAxis.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • test/state/selectors/radarSelectors.spec.tsx
**/storybook/**/*.stories.{ts,tsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

When adding new Storybook stories, prioritize high fidelity examples intended for publication on the website and in Storybook UI; use unit tests or VR tests for low fidelity tests

Files:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • test/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/util/getAxisTypeBasedOnLayout.ts
  • src/polar/defaultPolarAngleAxisProps.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/util/types.ts
  • src/state/cartesianAxisSlice.ts
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/tooltipSelectors.ts
  • src/cartesian/XAxis.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • src/state/selectors/axisSelectors.ts
  • src/polar/PolarRadiusAxis.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/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
🧠 Learnings (20)
📚 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 : Update Storybook stories when APIs have been changed to ensure they work as expected

Applied to files:

  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • scripts/snapshots/es6Files.txt
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • src/state/selectors/tooltipSelectors.ts
  • test/polar/PolarAngleAxis.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
  • test/state/selectors/radarSelectors.spec.tsx
📚 Learning: 2025-12-16T08:12:06.809Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:06.809Z
Learning: In tests (files under any test directory, e.g., test/, __tests__/, etc.), allow importing internal module paths (e.g., ../../src/...) and do not require imports to use the public API entry point (src/index.ts). The public API import restriction should apply only to non-test code. During reviews, accept internal imports in test files and enforce the public API pattern only for non-test code.

Applied to files:

  • test/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/helper/expectScale.ts
  • test/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.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/state/selectors/selectBaseAxis.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • src/cartesian/YAxis.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.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/state/selectors/selectBaseAxis.spec.tsx
  • test/polar/Radar.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/state/selectors/selectBaseAxis.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/polar/PolarAngleAxis.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/state/selectors/selectBaseAxis.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/polar/defaultPolarAngleAxisProps.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/cartesian/XAxis.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • src/polar/PolarRadiusAxis.tsx
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • test/helper/expectScale.ts
  • scripts/snapshots/es6Files.txt
  • src/state/cartesianAxisSlice.ts
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/cartesian/XAxis.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • src/state/selectors/axisSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
📚 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:

  • scripts/snapshots/typesFiles.txt
  • test/helper/expectScale.ts
  • src/state/cartesianAxisSlice.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/tooltipSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
📚 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/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/cartesian/ErrorBar.spec.tsx
  • src/util/scale/RechartsScale.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/YAxis.tsx
  • src/state/selectors/axisSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
📚 Learning: 2025-12-14T13:58:58.361Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:58.361Z
Learning: In the recharts codebase, `useAppSelector` and hooks like `useChartLayout()` are designed to return `undefined` when used outside Redux Provider context, rather than throwing errors. This allows components like `Curve` that call these hooks to work standalone by falling back to prop values.

Applied to files:

  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/tooltipSelectors.ts
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
  • test/state/selectors/radarSelectors.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/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/cartesian/ErrorBar.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: Add tests when adding new functionality or changing existing functionality; prefer unit tests for helper functions or RTL tests for rendering

Applied to files:

  • test/polar/Radar.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/polar/Radar.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.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/cartesian/ErrorBar.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/**/*.spec.{ts,tsx} : Aim for 100% unit test code coverage when writing new code

Applied to files:

  • test/cartesian/YAxis/YAxis.type.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:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
🧬 Code graph analysis (24)
test/state/selectors/selectBaseAxis.spec.tsx (2)
src/state/selectors/polarAxisSelectors.ts (2)
  • implicitAngleAxis (18-34)
  • implicitRadiusAxis (36-52)
src/state/selectors/axisSelectors.ts (1)
  • selectBaseAxis (209-229)
src/util/getAxisTypeBasedOnLayout.ts (2)
src/util/types.ts (4)
  • LayoutType (57-57)
  • AxisType (58-58)
  • AxisDomainTypeInput (79-79)
  • EvaluatedAxisDomainType (85-85)
src/util/ChartUtils.ts (1)
  • isCategoricalAxis (105-109)
test/chart/RadarChart.spec.tsx (1)
test/helper/expectScale.ts (1)
  • expectLastCalledWithScale (49-53)
test/cartesian/XAxis/XAxis.vertical.spec.tsx (1)
src/util/types.ts (1)
  • AxisDomainTypeInput (79-79)
test/helper/expectScale.ts (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
src/state/cartesianAxisSlice.ts (1)
src/util/types.ts (1)
  • EvaluatedAxisDomainType (85-85)
test/polar/Radar.spec.tsx (7)
test/helper/createSelectorTestCase.tsx (1)
  • createSelectorTestCase (78-139)
test/_data.ts (1)
  • exampleRadarData (201-210)
src/polar/Radar.tsx (1)
  • Radar (576-607)
src/state/selectors/polarAxisSelectors.ts (1)
  • selectRadiusAxis (83-95)
src/state/cartesianAxisSlice.ts (1)
  • defaultAxisId (20-20)
test/helper/expectLastCalledWith.ts (1)
  • expectLastCalledWith (14-34)
test/helper/expectRadarPolygons.ts (1)
  • expectRadarPolygons (14-25)
src/state/selectors/combiners/combineCheckedDomain.ts (3)
src/util/types.ts (2)
  • NumberDomain (757-757)
  • CategoricalDomain (761-761)
src/util/isDomainSpecifiedByUser.ts (1)
  • isWellFormedNumberDomain (6-14)
src/util/isWellBehavedNumber.ts (1)
  • isWellBehavedNumber (1-3)
test/component/Tooltip/Tooltip.sync.spec.tsx (3)
src/polar/PolarAngleAxis.tsx (1)
  • PolarAngleAxis (483-508)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (379-404)
test/component/Tooltip/tooltipTestHelpers.tsx (2)
  • expectTooltipPayload (140-152)
  • expectTooltipCoordinate (172-178)
src/polar/PolarAngleAxis.tsx (6)
src/util/types.ts (3)
  • AxisDomain (742-746)
  • AxisDomainTypeInput (79-79)
  • EvaluatedAxisDomainType (85-85)
src/state/polarAxisSlice.ts (1)
  • AngleAxisSettings (7-7)
src/context/chartLayoutContext.tsx (1)
  • usePolarChartLayout (154-156)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/state/selectors/polarAxisSelectors.ts (1)
  • selectAngleAxis (64-77)
src/util/DataUtils.ts (1)
  • noop (210-210)
src/state/selectors/polarScaleSelectors.ts (2)
src/state/selectors/axisSelectors.ts (1)
  • selectRealScaleType (1126-1130)
src/state/selectors/polarSelectors.ts (1)
  • selectPolarAxisCheckedDomain (172-179)
test/cartesian/ErrorBar.spec.tsx (1)
src/util/types.ts (1)
  • AxisDomainTypeInput (79-79)
test/component/Tooltip/Tooltip.visibility.spec.tsx (6)
src/polar/PolarAngleAxis.tsx (1)
  • PolarAngleAxis (483-508)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (379-404)
test/component/Tooltip/tooltipMouseHoverSelectors.ts (1)
  • radialBarChartMouseHoverTooltipSelector (35-35)
src/state/selectors/tooltipSelectors.ts (3)
  • selectTooltipAxisDomainIncludingNiceTicks (284-289)
  • selectTooltipAxisDomain (265-277)
  • selectTooltipAxisScale (303-311)
test/helper/expectLastCalledWith.ts (1)
  • expectLastCalledWith (14-34)
test/helper/expectScale.ts (1)
  • expectLastCalledWithScale (49-53)
test/cartesian/YAxis/YAxis.type.spec.tsx (6)
src/util/types.ts (1)
  • AxisDomainTypeInput (79-79)
src/cartesian/YAxis.tsx (1)
  • YAxis (359-359)
test/helper/createSelectorTestCase.tsx (1)
  • createSelectorTestCase (78-139)
src/state/selectors/axisSelectors.ts (1)
  • selectYAxisSettings (178-184)
src/state/cartesianAxisSlice.ts (1)
  • defaultAxisId (20-20)
test/helper/expectLastCalledWith.ts (1)
  • expectLastCalledWith (14-34)
src/state/selectors/polarSelectors.ts (5)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/util/types.ts (2)
  • NumberDomain (757-757)
  • CategoricalDomain (761-761)
src/state/selectors/axisSelectors.ts (1)
  • selectRealScaleType (1126-1130)
src/state/selectors/combiners/combineCheckedDomain.ts (1)
  • combineCheckedDomain (8-46)
src/state/selectors/tooltipSelectors.ts (2)
src/state/selectors/axisSelectors.ts (2)
  • selectTooltipAxis (562-566)
  • selectHasBar (282-284)
src/state/selectors/rootPropsSelectors.ts (1)
  • selectChartName (12-12)
test/polar/PolarAngleAxis.spec.tsx (5)
test/helper/expectScale.ts (1)
  • expectLastCalledWithScale (49-53)
src/state/selectors/polarScaleSelectors.ts (2)
  • selectPolarAxisScale (57-64)
  • selectPolarAxisTicks (75-93)
src/state/selectors/axisSelectors.ts (1)
  • selectRealScaleType (1126-1130)
test/helper/createSelectorTestCase.tsx (1)
  • createSelectorTestCase (78-139)
test/_data.ts (1)
  • PageData (4-11)
src/cartesian/XAxis.tsx (5)
src/util/types.ts (3)
  • AxisDomainTypeInput (79-79)
  • AxisDomain (742-746)
  • EvaluatedAxisDomainType (85-85)
src/state/cartesianAxisSlice.ts (2)
  • XAxisOrientation (24-24)
  • XAxisSettings (89-93)
src/state/hooks.ts (1)
  • useAppDispatch (9-15)
src/context/chartLayoutContext.tsx (1)
  • useCartesianChartLayout (138-144)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/context/chartLayoutContext.tsx (3)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/util/types.ts (1)
  • PolarLayout (51-51)
src/state/hooks.ts (1)
  • useAppSelector (40-50)
test/component/Tooltip/itemSorter.spec.tsx (3)
src/polar/PolarAngleAxis.tsx (1)
  • PolarAngleAxis (483-508)
src/index.ts (2)
  • PolarAngleAxis (54-54)
  • PolarRadiusAxis (52-52)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (379-404)
src/state/selectors/polarAxisSelectors.ts (5)
src/state/polarAxisSlice.ts (2)
  • AngleAxisSettings (7-7)
  • RadiusAxisSettings (5-5)
src/util/types.ts (2)
  • AxisDomainTypeInput (79-79)
  • PolarLayout (51-51)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/context/chartLayoutContext.tsx (1)
  • selectPolarChartLayout (146-152)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/state/selectors/axisSelectors.ts (5)
src/state/selectors/selectTooltipAxisType.ts (1)
  • RenderableAxisType (12-12)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/util/types.ts (2)
  • NumberDomain (757-757)
  • CategoricalDomain (761-761)
src/state/selectors/combiners/combineCheckedDomain.ts (1)
  • combineCheckedDomain (8-46)
src/util/scale/RechartsScale.ts (1)
  • RechartsScale (14-73)
src/polar/PolarRadiusAxis.tsx (5)
src/util/types.ts (3)
  • AxisDomainTypeInput (79-79)
  • AxisDomain (742-746)
  • EvaluatedAxisDomainType (85-85)
src/state/polarAxisSlice.ts (1)
  • RadiusAxisSettings (5-5)
src/context/chartLayoutContext.tsx (1)
  • usePolarChartLayout (154-156)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/util/DataUtils.ts (1)
  • noop (210-210)
test/state/selectors/radarSelectors.spec.tsx (1)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (379-404)
⏰ 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)

@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 94.53552% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.52%. Comparing base (5935b5c) to head (1ca1cca).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/cartesian/XAxis.tsx 78.94% 4 Missing ⚠️
src/cartesian/YAxis.tsx 78.94% 4 Missing ⚠️
src/polar/PolarAngleAxis.tsx 80.00% 4 Missing ⚠️
src/polar/PolarRadiusAxis.tsx 81.81% 4 Missing ⚠️
.../state/selectors/combiners/combineCheckedDomain.ts 91.66% 3 Missing ⚠️
src/state/selectors/polarAxisSelectors.ts 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6823      +/-   ##
==========================================
- Coverage   93.54%   93.52%   -0.03%     
==========================================
  Files         524      526       +2     
  Lines       46476    46724     +248     
  Branches     5057     5078      +21     
==========================================
+ Hits        43477    43697     +220     
- Misses       2992     3020      +28     
  Partials        7        7              

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

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: 0

♻️ Duplicate comments (5)
test/cartesian/YAxis/YAxis.type.spec.tsx (1)

75-89: Misleading prop name: xAxisType used for YAxis component in horizontal chart tests.

The horizontal chart TestCase uses xAxisType as the prop name, but it's being passed to YAxis. This is confusing and inconsistent with the vertical chart TestCase which correctly uses axisType.

🔎 Proposed fix
-    const TestCase = ({ children, xAxisType }: { children?: ReactNode; xAxisType?: AxisDomainTypeInput }) => {
+    const TestCase = ({ children, axisType }: { children?: ReactNode; axisType?: AxisDomainTypeInput }) => {
       return (
         <BarChart
           width={400}
           height={400}
           data={[
             { x: 12, y: 'A' },
             { x: 5, y: 'B' },
           ]}
         >
-          <YAxis type={xAxisType} dataKey="x" />
+          <YAxis type={axisType} dataKey="x" />
           {children}
         </BarChart>
       );
     };

Also update lines 102, 113, and 123 to use axisType instead of xAxisType.

Also applies to: 100-129

www/src/docs/api/PolarRadiusAxisAPI.tsx (1)

364-375: Documentation incorrectly references angles for PolarRadiusAxis.

The type prop description mentions "axis maps discrete categories to angles around the circle" which is accurate for PolarAngleAxis but incorrect for PolarRadiusAxis. The radius axis controls distance from the center, not angular positioning.

🔎 Suggested fix
             <p>
-              <code>category</code>: axis maps discrete categories to angles around the circle. Treats data as distinct
-              values. Each value is in the same distance from its neighbors, regardless of their actual numeric
+              <code>category</code>: axis maps discrete categories to radii from the center. Treats data as distinct
+              values. Each value is at an equal radial distance from its neighbors, regardless of their actual numeric
               difference.
             </p>
             <p>
               <code>number</code>: Treats data as continuous range. Values that are numerically closer are placed closer
-              together on the axis.
+              together along the radius.
             </p>
src/util/types.ts (1)

60-78: JSDoc uses polar-specific wording for shared axis types.

The JSDoc for AxisDomainTypeInput describes category as mapping "discrete categories to angles around the circle", but this type is used for all axes including Cartesian XAxis/YAxis where there are no angles or circles.

🔎 Suggested fix
 /**
  * The type of axis.
  *
- * `category`: axis maps discrete categories to angles around the circle.
+ * `category`: axis treats data as discrete distinct values.
- * Treats data as distinct values.
  * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
  *
  * `number`: Treats data as continuous range.
  * Values that are numerically closer are placed closer together on the axis.
  *
  * `auto`: the type is inferred based on the chart layout.
src/cartesian/XAxis.tsx (1)

43-57: Documentation incorrectly references polar axis behavior.

The JSDoc for type describes category as mapping "discrete categories to angles around the circle" which is polar axis behavior. This is the Cartesian XAxis component which positions values along a linear axis.

🔎 Suggested fix
   /**
    * The type of axis.
    *
-   * `category`: axis maps discrete categories to angles around the circle.
-   * Treats data as distinct values.
+   * `category`: axis treats data as discrete distinct values.
    * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
    *
-   * `number`: Treats data as continuous range.
+   * `number`: axis treats data as a continuous numeric range.
    * Values that are numerically closer are placed closer together on the axis.
    *
    * `auto`: the type is inferred based on the chart layout.
www/src/docs/api/XAxisAPI.tsx (1)

466-478: Documentation incorrectly references polar axis behavior for XAxis.

The type prop description mentions "axis maps discrete categories to angles around the circle" which applies to polar axes, not the Cartesian XAxis.

🔎 Suggested fix
             <p>
-              <code>category</code>: axis maps discrete categories to angles around the circle. Treats data as distinct
-              values. Each value is in the same distance from its neighbors, regardless of their actual numeric
+              <code>category</code>: axis treats data as discrete distinct values. Each value is placed at the same
+              distance from its neighbors, regardless of their actual numeric
               difference.
             </p>
             <p>
               <code>number</code>: Treats data as continuous range. Values that are numerically closer are placed closer
               together on the axis.
             </p>
🧹 Nitpick comments (1)
src/polar/PolarRadiusAxis.tsx (1)

197-208: Consider destructuring props outside useMemo to stabilize dependencies.

The useMemo depends on props object reference. If props is a new object on each render (common with spread or inline object creation), this could cause unnecessary recalculations even when prop values haven't changed.

🔎 Alternative approach

If performance becomes an issue, consider passing individual prop values to the dependency array or using a more granular memoization strategy. However, since this is a settings dispatcher that typically doesn't re-render frequently, the current implementation is likely acceptable.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1edfe0 and 187b198.

📒 Files selected for processing (11)
  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/YAxisAPI.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • src/cartesian/YAxis.tsx
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{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/YAxis/YAxis.type.spec.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • www/src/docs/api/XAxisAPI.tsx
  • src/cartesian/XAxis.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • src/polar/PolarAngleAxis.tsx
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • test/cartesian/YAxis/YAxis.type.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/YAxis/YAxis.type.spec.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • www/src/docs/api/XAxisAPI.tsx
  • src/cartesian/XAxis.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • src/polar/PolarAngleAxis.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/YAxis/YAxis.type.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/YAxis/YAxis.type.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/YAxis/YAxis.type.spec.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • www/src/docs/api/XAxisAPI.tsx
  • src/cartesian/XAxis.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • src/polar/PolarAngleAxis.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/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
🧠 Learnings (14)
📚 Learning: 2025-12-16T08:12:06.809Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:06.809Z
Learning: In tests (files under any test directory, e.g., test/, __tests__/, etc.), allow importing internal module paths (e.g., ../../src/...) and do not require imports to use the public API entry point (src/index.ts). The public API import restriction should apply only to non-test code. During reviews, accept internal imports in test files and enforce the public API pattern only for non-test code.

Applied to files:

  • test/cartesian/YAxis/YAxis.type.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/YAxis/YAxis.type.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/cartesian/YAxis/YAxis.type.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/**/*.spec.{ts,tsx} : Aim for 100% unit test code coverage when writing new code

Applied to files:

  • test/cartesian/YAxis/YAxis.type.spec.tsx
📚 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/YAxis/YAxis.type.spec.tsx
  • src/util/types.ts
📚 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/YAxis/YAxis.type.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 **/*.{ts,tsx} : Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions

Applied to files:

  • test/cartesian/YAxis/YAxis.type.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/cartesian/YAxis/YAxis.type.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/cartesian/YAxis/YAxis.type.spec.tsx
📚 Learning: 2025-12-08T08:23:26.261Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.261Z
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:

  • test/cartesian/YAxis/YAxis.type.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/cartesian/YAxis/YAxis.type.spec.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/polar/PolarRadiusAxis.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • src/polar/PolarRadiusAxis.tsx
  • src/util/types.ts
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.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:

  • src/polar/PolarRadiusAxis.tsx
  • src/polar/PolarAngleAxis.tsx
🧬 Code graph analysis (3)
test/cartesian/YAxis/YAxis.type.spec.tsx (4)
src/util/types.ts (1)
  • AxisDomainTypeInput (78-78)
src/cartesian/YAxis.tsx (1)
  • YAxis (358-358)
src/state/selectors/axisSelectors.ts (1)
  • selectYAxisSettings (178-184)
src/state/cartesianAxisSlice.ts (1)
  • defaultAxisId (20-20)
src/cartesian/XAxis.tsx (4)
src/util/types.ts (3)
  • AxisDomainTypeInput (78-78)
  • AxisDomain (741-745)
  • EvaluatedAxisDomainType (84-84)
src/state/cartesianAxisSlice.ts (2)
  • XAxisOrientation (24-24)
  • XAxisSettings (89-93)
src/context/chartLayoutContext.tsx (1)
  • useCartesianChartLayout (138-144)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/polar/PolarAngleAxis.tsx (5)
src/util/types.ts (3)
  • AxisDomain (741-745)
  • AxisDomainTypeInput (78-78)
  • EvaluatedAxisDomainType (84-84)
src/state/polarAxisSlice.ts (1)
  • AngleAxisSettings (7-7)
src/context/chartLayoutContext.tsx (1)
  • usePolarChartLayout (154-156)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/util/DataUtils.ts (1)
  • noop (210-210)
⏰ 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). (1)
  • GitHub Check: Build, Test, Pack
🔇 Additional comments (9)
test/cartesian/YAxis/YAxis.type.spec.tsx (1)

1-71: Well-structured tests for YAxis type behavior.

The vertical chart tests correctly cover default type, explicit types ("number", "category"), and the new "auto" inference. The test structure follows project guidelines using createSelectorTestCase and expectLastCalledWith.

www/src/docs/api/PolarRadiusAxisAPI.tsx (1)

267-294: Scale prop documentation looks good.

The new scale prop documentation correctly explains the mapping between data domain and coordinate range, with appropriate examples including d3-scale usage.

src/util/types.ts (1)

80-84: Clear separation between input and evaluated types.

The introduction of EvaluatedAxisDomainType to represent the resolved type after inferring 'auto' is a clean design. This separates the public API surface (AxisDomainTypeInput) from the internal representation.

src/polar/PolarRadiusAxis.tsx (1)

194-218: Layout-aware type inference is correctly implemented.

The implementation properly:

  • Uses usePolarChartLayout which returns undefined outside Provider context (per project patterns)
  • Guards against undefined evaluatedType to prevent premature dispatch
  • Uses noop for cleanup when settings is null
  • Memoizes derived settings with useMemo
src/cartesian/XAxis.tsx (1)

154-181: Clean implementation of layout-aware type inference.

The refactored SetXAxisSettings properly:

  • Extracts typeFromProps for layout-based evaluation
  • Uses useMemo to derive settings with the evaluated type
  • Guards against null settings before dispatching
  • Maintains existing add/replace/remove dispatch logic
src/polar/PolarAngleAxis.tsx (2)

173-185: Documentation correctly describes polar angle axis behavior.

Unlike the Cartesian axes, this documentation correctly references "angles around the circle" since PolarAngleAxis actually maps values to angular positions around the polar chart.


255-286: Layout-aware type inference implementation is consistent with other axes.

The implementation properly:

  • Uses usePolarChartLayout for polar layout detection
  • Derives settings with evaluated type via useMemo
  • Guards against null settings before dispatch
  • Uses noop for cleanup when settings is undefined
www/src/docs/api/XAxisAPI.tsx (1)

133-161: Good documentation enhancements for domain and scale props.

The expanded documentation for domain and scale props provides clear guidance with helpful usage examples, including d3-scale integration patterns.

Also applies to: 331-358

www/src/docs/api/PolarAngleAxisAPI.tsx (1)

311-338: Documentation updates are correct and appropriate.

The scale prop documentation is well-written with helpful examples. The type prop correctly:

  • Includes the new 'auto' option
  • Updates default to 'auto'
  • Appropriately describes "angles around the circle" since this is a polar angle axis

Also applies to: 424-446

@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 25, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.19MB 9.24kB (0.78%) ⬆️
recharts/bundle-es6 1.03MB 8.7kB (0.85%) ⬆️
recharts/bundle-umd 526.41kB 3.42kB (0.65%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js -34 bytes 64.06kB -0.05%
util/ChartUtils.js -619 bytes 19.88kB -3.02%
state/selectors/tooltipSelectors.js -85 bytes 17.6kB -0.48%
polar/PolarAngleAxis.js 669 bytes 12.63kB 5.59% ⚠️
polar/PolarRadiusAxis.js 815 bytes 11.54kB 7.6% ⚠️
cartesian/YAxis.js 2.04kB 10.97kB 22.83% ⚠️
cartesian/XAxis.js 2.04kB 9.52kB 27.24% ⚠️
context/chartLayoutContext.js 448 bytes 9.25kB 5.09% ⚠️
state/selectors/polarAxisSelectors.js 956 bytes 8.73kB 12.29% ⚠️
util/types.js 769 bytes 7.98kB 10.67% ⚠️
state/selectors/polarSelectors.js 340 bytes 4.89kB 7.48% ⚠️
util/scale/RechartsScale.js -307 bytes 4.1kB -6.96%
state/selectors/polarScaleSelectors.js -11 bytes 3.48kB -0.32%
state/selectors/combiners/combineCheckedDomain.js (New) 1.58kB 1.58kB 100.0% 🚀
polar/defaultPolarAngleAxisProps.js -4 bytes 749 bytes -0.53%
util/getAxisTypeBasedOnLayout.js (New) 647 bytes 647 bytes 100.0% 🚀
polar/defaultPolarRadiusAxisProps.js -2 bytes 642 bytes -0.31%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js -37 bytes 54.05kB -0.07%
util/ChartUtils.js -548 bytes 17.86kB -2.98%
state/selectors/tooltipSelectors.js -42 bytes 14.17kB -0.3%
polar/PolarAngleAxis.js 598 bytes 11.22kB 5.63% ⚠️
polar/PolarRadiusAxis.js 741 bytes 10.13kB 7.9% ⚠️
cartesian/YAxis.js 1.98kB 9.55kB 26.24% ⚠️
cartesian/XAxis.js 1.98kB 8.14kB 32.2% ⚠️
context/chartLayoutContext.js 279 bytes 7.92kB 3.65%
util/types.js 769 bytes 7.56kB 11.32% ⚠️
state/selectors/polarAxisSelectors.js 1.22kB 7.02kB 20.99% ⚠️
state/selectors/polarSelectors.js 217 bytes 3.86kB 5.95% ⚠️
util/scale/RechartsScale.js -298 bytes 3.25kB -8.41%
state/selectors/polarScaleSelectors.js -22 bytes 2.85kB -0.77%
state/selectors/combiners/combineCheckedDomain.js (New) 1.36kB 1.36kB 100.0% 🚀
polar/defaultPolarAngleAxisProps.js -4 bytes 577 bytes -0.69%
util/getAxisTypeBasedOnLayout.js (New) 504 bytes 504 bytes 100.0% 🚀
polar/defaultPolarRadiusAxisProps.js -2 bytes 468 bytes -0.43%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 3.42kB 526.41kB 0.65%

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

1 similar comment
@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.

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: 0

♻️ Duplicate comments (1)
www/src/docs/api/PolarRadiusAxisAPI.tsx (1)

267-294: PolarRadiusAxis scale / type docs are aligned; minor copy nits remain.

The new scale section and the updated type: "number" | "auto" | "category" with default 'auto' match the new PolarRadiusAxis behavior, and the earlier issue of talking about “angles around the circle” for the radius axis is gone.

Two small follow-ups you might consider:

  1. Fix the tense in the scale description (same as YAxis):

    Suggested wording tweak
  •          Scale function determines how data values are mapped to visual values. In other words, decided the mapping
    
  •          between data domain and coordinate range.
    
  •          Scale function determines how data values are mapped to visual values. In other words, it decides the
    
  •          mapping between data domain and coordinate range.
    
    </details>
    
    
  1. For type, you could make it explicit that this axis controls radius (distance from the center), e.g. “category: map discrete categories to evenly spaced radii; number: map continuous numeric values to radii proportional to their magnitude; auto: infer between the two based on layout”. The current generic wording is correct but a bit abstract for a radius axis.

Also applies to: 357-379

🧹 Nitpick comments (7)
test/cartesian/YAxis/YAxis.type.spec.tsx (1)

37-39: Consider verifying selector call counts.

Per coding guidelines, consider verifying the number of selector calls using the spy object to spot unnecessary re-renders. This helps ensure the axis type resolution doesn't trigger excessive recalculations.

         const { spy } = renderTestCase(state => selectYAxisSettings(state, defaultAxisId));
         expectLastCalledWith(spy, expect.objectContaining({ type: 'number' }));
+        expect(spy).toHaveBeenCalledTimes(2); // initial + stabilized render
test/polar/Radar.spec.tsx (1)

15-75: Nice selector-based harness for implicit polar axes.

The new createSelectorTestCase wrapper and selectRadiusAxis(defaultAxisId) assertion look consistent with the implicit numeric radius axis and the new scale: 'auto' / type: 'number' behavior, and reusing the wrapper for the polygon test keeps the coverage tight.

If you want to squeeze a bit more signal out of the selector test, you could also assert the expected number of spy calls (e.g. expect(spy).toHaveBeenCalledTimes(1)) to catch accidental extra renders in the future, but the current tests are fine as-is.

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

1283-1936: RadialBarChart axis binding and tooltip expectations align with new semantics.

Swapping the RadialBar axes to PolarAngleAxis dataKey="uv" and PolarRadiusAxis dataKey="name" in these tests matches the RadialBar layout (value by angle, category by radius), and the updated tooltip payloads and deep payload/geometry assertions are internally consistent with that mapping across the various itemSorter modes.

If the radial geometry implementation keeps evolving, you might eventually want to assert a smaller set of invariants (e.g. correct label, value, and a couple of key radii) instead of full payload objects to reduce maintenance, but for now these strict expectations give strong regression coverage.

www/src/docs/api/YAxisAPI.tsx (1)

319-346: YAxis scale / type docs match the new behavior; just a tiny wording fix.

The new scale section correctly explains 'auto' and custom scales, and the type docs now describe category / number / auto in cartesian terms (no more polar/angle wording), which aligns with the implementation.

Only nit: the sentence “In other words, decided the mapping between data domain and coordinate range.” should use present tense.

Suggested wording tweak
-              Scale function determines how data values are mapped to visual values. In other words, decided the mapping
-              between data domain and coordinate range.
+              Scale function determines how data values are mapped to visual values. In other words, it decides the
+              mapping between data domain and coordinate range.

Also applies to: 448-465

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

200-220: RadialBarChart sync setup and expectations look consistent with the new axis behavior.

Using <PolarAngleAxis /> with <PolarRadiusAxis dataKey="name" /> in RadialBarChartTestCase plus the updated tooltip expectations (Mike with values 200 / 9800 at label Page D) matches the adjusted radial semantics and keeps the synchronization tests targeting a clear data point (index '3').

The detailed active-coordinate and tooltip-coordinate checks give strong regression coverage; if radial positioning changes again in the future you might consider asserting a subset of properties (label, value, and approximate radius) rather than every numeric field to reduce brittleness, but nothing here blocks the PR.

Also applies to: 587-703

test/polar/PolarRadiusAxis.spec.tsx (1)

846-887: Tick coordinate / label snapshots look consistent but are very brittle.

The revised tick positions and labels for RadialBar radius axes (both categorical and numeric, including the new tickCount case) correctly reflect the changed domains and scales. Just be aware these pixel-perfect expectations will need updating for even minor layout math tweaks; if that becomes noisy in future, consider factoring some of these into more semantic checks (e.g., counts, ordering, and monotonicity) and leaving full coordinate snapshots only where strictly necessary.

Also applies to: 960-995, 1071-1111, 1121-1155

src/util/types.ts (1)

60-83: Axis-domain input vs evaluated types are well factored; minor doc/alias duplication only.

Defining AxisDomainTypeInput (with auto) separately from EvaluatedAxisDomainType (no auto) matches how axes now resolve types before hitting the store, and the updated BaseAxisProps.type JSDoc is clear and axis‑agnostic. The only small nit is that BaseAxisProps.type re‑states the same union and description already expressed on AxisDomainTypeInput; if you ever want to reduce duplication, you could have BaseAxisProps.type?: AxisDomainTypeInput and rely on the shared JSDoc.

Also applies to: 763-776

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e904dc6 and 1ca1cca.

⛔ Files ignored due to path filters (6)
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Data-Keys-1-webkit-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/RadialBarChart.spec-vr.tsx-snapshots/Rings-With-Default-Axes-1-webkit-linux.png is excluded by !**/*.png
📒 Files selected for processing (49)
  • scripts/snapshots/es6Files.txt
  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/context/chartLayoutContext.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/polar/PolarRadiusAxis.tsx
  • src/polar/defaultPolarAngleAxisProps.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/state/cartesianAxisSlice.ts
  • src/state/selectors/axisSelectors.ts
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • src/state/selectors/polarAxisSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/tooltipSelectors.ts
  • src/util/ChartUtils.ts
  • src/util/getAxisTypeBasedOnLayout.ts
  • src/util/scale/RechartsScale.ts
  • src/util/types.ts
  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • storybook/stories/API/polar/RadialBar.stories.tsx
  • test/cartesian/ErrorBar.spec.tsx
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/chart/RadarChart.spec.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/helper/expectScale.ts
  • test/polar/PolarAngleAxis.spec.tsx
  • test/polar/PolarGrid.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/polar/Radar.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/state/selectors/axisSelectors.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/state/selectors/selectBaseAxis.spec.tsx
  • test/util/ChartUtils/checkDomainOfScale.spec.ts
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • www/src/docs/api/XAxisAPI.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • www/src/docs/api/ZAxisAPI.tsx
  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
💤 Files with no reviewable changes (3)
  • test/util/ChartUtils/checkDomainOfScale.spec.ts
  • storybook/stories/API/polar/RadialBar.stories.tsx
  • src/util/ChartUtils.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • scripts/snapshots/typesFiles.txt
  • test/state/selectors/axisSelectors.spec.tsx
  • test/helper/expectScale.ts
  • src/context/chartLayoutContext.tsx
  • test/chart/RadarChart.spec.tsx
  • src/util/getAxisTypeBasedOnLayout.ts
  • test/polar/PolarGrid.spec.tsx
  • storybook/stories/API/polar/PolarAngleAxis.stories.tsx
  • test/polar/RadialBar.spec.tsx
  • storybook/stories/API/polar/PolarRadiusAxis.stories.tsx
  • src/state/selectors/combiners/combineCheckedDomain.ts
  • test/cartesian/ErrorBar.spec.tsx
  • src/polar/defaultPolarAngleAxisProps.tsx
  • scripts/snapshots/es6Files.txt
  • test/cartesian/XAxis/XAxis.type.spec.tsx
  • www/src/docs/api/XAxisAPI.tsx
  • scripts/snapshots/libFiles.txt
  • src/state/selectors/polarScaleSelectors.ts
  • test/state/selectors/selectBaseAxis.spec.tsx
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{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

All imports from recharts must use the public API entry point (e.g., import { TooltipIndex } from 'recharts'). Imports from internal paths like recharts/types/* or recharts/src/* are not allowed and will fail the linter.

Files:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/tooltipSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • www/src/docs/api/ZAxisAPI.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/util/types.ts
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • src/state/selectors/axisSelectors.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/tooltipSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • www/src/docs/api/ZAxisAPI.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/util/types.ts
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • www/src/docs/api/PolarAngleAxisAPI.tsx
  • www/src/docs/api/PolarRadiusAxisAPI.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • www/src/docs/api/YAxisAPI.tsx
  • src/state/selectors/axisSelectors.ts
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/selectors/tooltipSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/util/scale/RechartsScale.ts
  • src/util/types.ts
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • src/state/selectors/axisSelectors.ts
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.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/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.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/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.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

Unit tests should be placed in the test directory, with some tests also allowed in www/test. Test files follow the naming convention *.spec.tsx.

Files:

  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
🧠 Learnings (20)
📚 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:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/tooltipSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • src/util/types.ts
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • src/state/selectors/axisSelectors.ts
📚 Learning: 2025-12-26T15:59:11.238Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.238Z
Learning: Applies to **/*.{ts,tsx} : All imports from `recharts` must use the public API entry point (e.g., `import { TooltipIndex } from 'recharts'`). Imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed and will fail the linter.

Applied to files:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/tooltipSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • src/polar/PolarAngleAxis.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/Radar.spec.tsx
  • src/state/selectors/axisSelectors.ts
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/polarSelectors.ts
  • src/polar/PolarRadiusAxis.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/util/scale/RechartsScale.ts
  • src/state/selectors/polarAxisSelectors.ts
  • src/cartesian/YAxis.tsx
  • src/state/cartesianAxisSlice.ts
  • src/state/selectors/axisSelectors.ts
📚 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:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
📚 Learning: 2025-12-14T13:58:58.361Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:58.361Z
Learning: In the recharts codebase, `useAppSelector` and hooks like `useChartLayout()` are designed to return `undefined` when used outside Redux Provider context, rather than throwing errors. This allows components like `Curve` that call these hooks to work standalone by falling back to prop values.

Applied to files:

  • www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx
  • src/state/selectors/tooltipSelectors.ts
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • src/util/scale/RechartsScale.ts
  • test/polar/PolarAngleAxis.spec.tsx
  • src/state/selectors/polarAxisSelectors.ts
  • test/state/selectors/radarSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • src/state/selectors/axisSelectors.ts
📚 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:

  • src/state/selectors/tooltipSelectors.ts
  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
  • src/state/selectors/axisSelectors.ts
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/polar/PolarRadiusAxis.tsx
  • src/cartesian/XAxis.tsx
  • src/polar/PolarAngleAxis.tsx
  • src/polar/defaultPolarRadiusAxisProps.tsx
  • src/cartesian/YAxis.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/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/Radar.spec.tsx
📚 Learning: 2025-12-16T08:12:06.809Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:06.809Z
Learning: In tests (files under any test directory, e.g., test/, __tests__/, etc.), allow importing internal module paths (e.g., ../../src/...) and do not require imports to use the public API entry point (src/index.ts). The public API import restriction should apply only to non-test code. During reviews, accept internal imports in test files and enforce the public API pattern only for non-test code.

Applied to files:

  • test/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.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/component/Tooltip/Tooltip.sync.spec.tsx
  • test/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.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/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.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/Tooltip.visibility.spec.tsx
  • test/polar/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/polar/Radar.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/component/Tooltip/Tooltip.visibility.spec.tsx
  • test/polar/Radar.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/**/*.spec.{ts,tsx} : Aim for 100% unit test code coverage when writing new code

Applied to files:

  • test/polar/PolarAngleAxis.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/PolarAngleAxis.spec.tsx
  • test/state/selectors/radarSelectors.spec.tsx
  • test/polar/Radar.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/state/selectors/radarSelectors.spec.tsx
  • src/cartesian/YAxis.tsx
  • test/polar/PolarRadiusAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
📚 Learning: 2025-12-26T15:59:11.238Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.238Z
Learning: Applies to test-vr/**/*.spec.ts : Visual regression tests should follow the naming convention `*.spec.ts` and be placed in the `test-vr` directory. When updating snapshots, new files created in `test-vr/__snapshots__` should be committed to the repository.

Applied to files:

  • test/state/selectors/radarSelectors.spec.tsx
  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.spec.tsx
📚 Learning: 2025-12-26T15:59:11.238Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.238Z
Learning: Applies to **/*.spec.{ts,tsx} : Unit tests should be placed in the `test` directory, with some tests also allowed in `www/test`. Test files follow the naming convention `*.spec.tsx`.

Applied to files:

  • test/cartesian/YAxis/YAxis.type.spec.tsx
📚 Learning: 2025-12-26T15:59:11.238Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.238Z
Learning: For release testing, use `yalc` to test Recharts changes in a test package as close as possible to the results of `npm publish` to ensure no unintended breaking changes are published.

Applied to files:

  • test/cartesian/YAxis/YAxis.type.spec.tsx
  • test/polar/Radar.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/Radar.spec.tsx
🧬 Code graph analysis (14)
src/state/selectors/tooltipSelectors.ts (2)
src/state/selectors/axisSelectors.ts (2)
  • selectTooltipAxis (561-565)
  • selectHasBar (281-283)
src/state/selectors/rootPropsSelectors.ts (1)
  • selectChartName (12-12)
src/state/selectors/polarSelectors.ts (5)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/util/types.ts (2)
  • NumberDomain (755-755)
  • CategoricalDomain (759-759)
src/state/selectors/axisSelectors.ts (1)
  • selectRealScaleType (1125-1129)
src/state/selectors/combiners/combineCheckedDomain.ts (1)
  • combineCheckedDomain (8-46)
src/polar/PolarRadiusAxis.tsx (5)
src/util/types.ts (3)
  • AxisDomainTypeInput (77-77)
  • AxisDomain (740-744)
  • EvaluatedAxisDomainType (83-83)
src/state/hooks.ts (1)
  • useAppDispatch (9-15)
src/context/chartLayoutContext.tsx (1)
  • usePolarChartLayout (154-156)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/util/DataUtils.ts (1)
  • noop (210-210)
test/component/Tooltip/Tooltip.sync.spec.tsx (3)
src/polar/PolarAngleAxis.tsx (1)
  • PolarAngleAxis (481-506)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (377-402)
test/component/Tooltip/tooltipTestHelpers.tsx (2)
  • expectTooltipPayload (140-152)
  • expectTooltipCoordinate (172-178)
src/cartesian/XAxis.tsx (4)
src/util/types.ts (3)
  • AxisDomainTypeInput (77-77)
  • AxisDomain (740-744)
  • EvaluatedAxisDomainType (83-83)
src/state/cartesianAxisSlice.ts (2)
  • XAxisOrientation (24-24)
  • XAxisSettings (89-93)
src/context/chartLayoutContext.tsx (1)
  • useCartesianChartLayout (138-144)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/polar/PolarAngleAxis.tsx (6)
src/util/types.ts (3)
  • AxisDomain (740-744)
  • AxisDomainTypeInput (77-77)
  • EvaluatedAxisDomainType (83-83)
src/state/polarAxisSlice.ts (1)
  • AngleAxisSettings (7-7)
src/context/chartLayoutContext.tsx (1)
  • usePolarChartLayout (154-156)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/state/selectors/polarAxisSelectors.ts (1)
  • selectAngleAxis (64-77)
src/util/DataUtils.ts (1)
  • noop (210-210)
test/component/Tooltip/Tooltip.visibility.spec.tsx (6)
src/polar/PolarAngleAxis.tsx (1)
  • PolarAngleAxis (481-506)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (377-402)
src/polar/RadialBar.tsx (1)
  • RadialBar (662-687)
test/component/Tooltip/tooltipMouseHoverSelectors.ts (1)
  • radialBarChartMouseHoverTooltipSelector (35-35)
test/helper/expectLastCalledWith.ts (1)
  • expectLastCalledWith (14-34)
test/helper/expectScale.ts (1)
  • expectLastCalledWithScale (49-53)
src/util/scale/RechartsScale.ts (1)
test/cartesian/ReferenceLine/getEndPoints.spec.tsx (1)
  • range (12-14)
src/state/selectors/polarAxisSelectors.ts (5)
src/state/polarAxisSlice.ts (2)
  • AngleAxisSettings (7-7)
  • RadiusAxisSettings (5-5)
src/util/types.ts (2)
  • AxisDomainTypeInput (77-77)
  • PolarLayout (51-51)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/context/chartLayoutContext.tsx (1)
  • selectPolarChartLayout (146-152)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
test/state/selectors/radarSelectors.spec.tsx (1)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (377-402)
src/cartesian/YAxis.tsx (5)
src/util/types.ts (3)
  • AxisDomainTypeInput (77-77)
  • AxisDomain (740-744)
  • EvaluatedAxisDomainType (83-83)
src/state/cartesianAxisSlice.ts (1)
  • YAxisSettings (97-102)
src/state/hooks.ts (1)
  • useAppDispatch (9-15)
src/context/chartLayoutContext.tsx (1)
  • useCartesianChartLayout (138-144)
src/util/getAxisTypeBasedOnLayout.ts (1)
  • getAxisTypeBasedOnLayout (8-20)
src/state/cartesianAxisSlice.ts (1)
src/util/types.ts (1)
  • EvaluatedAxisDomainType (83-83)
test/polar/PolarRadiusAxis.spec.tsx (3)
src/state/selectors/polarAxisSelectors.ts (1)
  • implicitRadiusAxis (36-52)
src/polar/PolarRadiusAxis.tsx (1)
  • PolarRadiusAxis (377-402)
src/state/polarAxisSlice.ts (1)
  • RadiusAxisSettings (5-5)
src/state/selectors/axisSelectors.ts (5)
src/util/types.ts (3)
  • D3ScaleType (185-200)
  • NumberDomain (755-755)
  • CategoricalDomain (759-759)
src/state/selectors/selectTooltipAxisType.ts (1)
  • RenderableAxisType (12-12)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (19-19)
src/state/selectors/combiners/combineCheckedDomain.ts (1)
  • combineCheckedDomain (8-46)
src/util/scale/RechartsScale.ts (1)
  • RechartsScale (14-73)
⏰ 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 (34)
src/util/scale/RechartsScale.ts (2)

110-114: LGTM! Consistent with the fixed tuple representation.

The change from range[range.length - 1] to range[1] is more explicit and aligns perfectly with the [number, number] tuple computed on line 104. The comparison logic correctly handles both ascending and descending ranges.


103-104: Good defensive programming to ensure a fixed min/max tuple.

The explicit extraction of d3Range and computation of [min, max] ensures the range is a proper two-element tuple regardless of d3's internal representation. Both variables have explicit types (ReadonlyArray<number> and [number, number]), which is appropriate defensive programming and aligns with the immutability principle noted in the file header.

The code is correct and follows all type safety guidelines.

src/polar/defaultPolarRadiusAxisProps.tsx (1)

21-21: LGTM! Default type changed to 'auto' for polar radius axis.

This change aligns with the PR objectives to restore correct default behavior for polar axes. The 'auto' type will be resolved at runtime based on the chart layout, enabling proper categorical/numerical axis inference.

test/state/selectors/radarSelectors.spec.tsx (3)

35-35: Test configuration updated to use explicit dataKey.

The addition of dataKey="value" to PolarRadiusAxis makes the test configuration explicit and aligns with the new axis behavior. This ensures the selector tests properly validate the new default 'auto' type resolution.


48-48: Expected name field updated to reflect index-based naming.

The change from value-based names (420, 460, etc.) to sequential indices (0, 1, 2...) correctly reflects the new behavior when PolarRadiusAxis has an explicit dataKey. The payload values remain unchanged, confirming only the name interpretation has changed.


556-556: Scale range orientation corrected.

The range change from [90, -270] to [-270, 90] reflects the corrected angle axis orientation behavior introduced by this PR. This ensures consistent scale range representation across polar axis selectors.

www/src/docs/exampleComponents/RadialBarChart/SimpleRadialBarChart.tsx (1)

1-1: LGTM! Tooltip added to the RadialBarChart example.

The import correctly uses the public API entry point from recharts. Adding <Tooltip /> enhances the documentation example by demonstrating tooltip integration with RadialBarChart.

test/cartesian/YAxis/YAxis.ticks.spec.tsx (1)

73-73: Scale range orientation normalized.

The range change from [265, 5] to [5, 265] normalizes the internal scale representation. Tick coordinates remain unchanged (265, 200, 135, 70, 5), confirming the visual output is preserved while the internal representation is corrected.

test/cartesian/YAxis/YAxis.type.spec.tsx (2)

1-9: LGTM! Comprehensive test coverage for YAxis type handling.

The new test file properly covers:

  • Default type behavior for both vertical and horizontal layouts
  • Explicit "number" and "category" type settings
  • The new "auto" type inference based on layout

The test correctly uses createSelectorTestCase and expectLastCalledWith helpers as per coding guidelines. Internal imports are acceptable in test files.


64-71: Auto type inference correctly tested for vertical layout.

The test validates that type="auto" correctly infers "category" for YAxis in a vertical BarChart, matching the expected layout-aware behavior where YAxis represents the categorical dimension.

www/src/docs/api/ZAxisAPI.tsx (1)

96-118: LGTM! ZAxis scale prop documentation updated.

The documentation clearly explains:

  • Scale function's role in mapping data domain to coordinate range
  • Default 'auto' behavior
  • Custom scale options (d3 shortcuts and full scale definitions)

The format examples correctly reference ZAxis instead of other axis components.

src/state/cartesianAxisSlice.ts (2)

3-11: LGTM! Import updated to use EvaluatedAxisDomainType.

The import change reflects the separation between:

  • AxisDomainTypeInput: User-facing prop type ('number' | 'category' | 'auto')
  • EvaluatedAxisDomainType: Internal state type ('number' | 'category')

This ensures the Redux state only stores resolved axis types.


34-37: Well-documented type constraint.

The comment clearly explains that axis type must be evaluated (resolved from 'auto' to 'number' or 'category') before creating the BaseCartesianAxis object. This ensures the Redux state always contains a concrete axis type.

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

96-99: Confirm combineRealScaleType signature matches reduced inputs.

The selector correctly passes 3 inputs (selectTooltipAxis, selectHasBar, selectChartName) that match the combineRealScaleType function signature (3 parameters: axisConfig, hasBar, chartType). The implementation properly destructures axisConfig to access scale and type information, confirming this is a valid simplification.

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

32-32: selectPolarAxisCheckedDomain wiring looks correct.

selectPolarAxisCheckedDomain cleanly composes selectRealScaleType and selectPolarAxisDomainIncludingNiceTicks through combineCheckedDomain, with matching parameter order and types. This gives polar charts the same “checked domain” behavior as cartesian axes without altering existing selectors.

No changes needed from my side.

Also applies to: 173-180

test/polar/PolarRadiusAxis.spec.tsx (1)

440-477: Axis-type and domain expectations align with new auto semantics.

The updated expectations for type (number for Radar implicit/default, category for RadialBar implicit/default) and the switch to categorical domains [0, 1, 2, 3, 4, 5] in RadialBar cases are consistent with the new AxisDomainTypeInput + layout-based inference. The selector call-count assertions also look reasonable for catching extra recomputations.

Also applies to: 721-845, 1008-1069

src/polar/PolarAngleAxis.tsx (1)

9-17: Layout‑aware type="auto" handling in PolarAngleAxis looks correct and robust.

Using AxisDomainTypeInput on the public prop, evaluating it via getAxisTypeBasedOnLayout with usePolarChartLayout, and only dispatching when an EvaluatedAxisDomainType exists gives the right behavior for auto while still honoring explicit 'number' | 'category'. The SetAngleAxisSettings memoization + settingsAreSynchronized guard cleanly avoid rendering until Redux state matches, and the noop early return keeps the effect well-typed when no settings are produced (e.g., outside a chart context).

Also applies to: 30-33, 114-115, 172-185, 249-285

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

64-71: Tooltip selector wiring and RadialBar tooltip expectations match the new radius-axis behavior.

Importing and exercising selectTooltipAxisDomain / selectTooltipAxisDomainIncludingNiceTicks in the RadialBarChart selector test is a good addition; the expectations for a categorical radius axis (dataKey: 'name', categorical domain of Page APage F, band scale, and per-category ticks with consistent offsets) align with the updated polar axis semantics and the RadialBar test wrapper that binds PolarRadiusAxis to name.

Also applies to: 267-281, 1314-1376

src/cartesian/YAxis.tsx (1)

2-14: YAxis type="auto" evaluation and Redux synchronization look solid.

Switching YAxisProps.type to AxisDomainTypeInput with the updated JSDoc, and having SetYAxisSettings derive an EvaluatedAxisDomainType via getAxisTypeBasedOnLayout + useCartesianChartLayout, gives consistent behavior with XAxis and polar axes. The memoized settings plus the prevSettingsRef/replaceYAxis logic maintain the existing registration semantics, while the early return when settings is null correctly no-ops for auto when layout is unavailable (e.g., outside a Cartesian chart), without introducing re-render loops.

Also applies to: 40-41, 56-69, 91-92, 166-205

src/cartesian/XAxis.tsx (1)

5-17: Cartesian XAxis now supports type="auto" with correct layout-based inference.

The introduction of AxisDomainTypeInput on XAxisProps.type (with cartesian-appropriate documentation) and the new SetXAxisSettings logic that evaluates auto via getAxisTypeBasedOnLayout + useCartesianChartLayout matches the YAxis pattern and the util types. The guarded effect prevents dispatch when no evaluated type is available, and the prevSettingsRef/replaceXAxis handling preserves existing registration semantics without introducing extra renders.

Also applies to: 39-40, 42-57, 79-80, 102-103, 153-192

www/src/docs/api/PolarAngleAxisAPI.tsx (1)

311-338: PolarAngleAxis API docs now match the implementation (type="auto" and scale).

The new scale section and the revised type prop definition ("number" | "auto" | "category" with default 'auto') correctly describe the component’s current behavior and the shared axis semantics. This will keep generated docs and IntelliSense consistent with the code changes across polar axes.

Also applies to: 424-446

src/polar/PolarRadiusAxis.tsx (1)

2-3: PolarRadiusAxis type="auto" integration and settings registration look consistent and safe.

Updating PolarRadiusAxisProps.type to AxisDomainTypeInput with the shared category/number/auto description, and having SetRadiusAxisSettings evaluate it via getAxisTypeBasedOnLayout + usePolarChartLayout before dispatching, brings radius-axis behavior in line with the rest of the axis system. The effect’s early settings == null guard plus noop cleanup correctly avoid registering anything when no evaluated type is available, while still ensuring addRadiusAxis/removeRadiusAxis are paired whenever a concrete RadiusAxisSettings exists.

Also applies to: 20-22, 33-36, 62-75, 102-103, 193-218, 377-399

src/state/selectors/axisSelectors.ts (3)

88-89: LGTM: New imports support domain validation.

The new imports for RechartsScale, rechartsScaleFactory, and combineCheckedDomain are well-organized and support the domain validation logic introduced in this PR.


1129-1129: LGTM: Simplified selector dependencies.

The reduction of dependencies from a larger set to just [selectBaseAxis, selectHasBar, selectChartName] simplifies the selector and improves performance by reducing unnecessary recomputations.


1464-1472: LGTM: Domain validation selector is well-implemented.

The new selectCheckedAxisDomain selector properly validates axis domains before scale creation. The selector is:

  • Correctly marked as internal (not exported)
  • Properly memoized with createSelector
  • Well-integrated with existing selectors

This aligns with the PR's goal of adding domain shape guards to prevent scale mutations.

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

1578-1769: LGTM: Comprehensive test coverage for RadialBarChart default axis.

The additions/updates properly test:

  • Axis settings with type: 'number' (correct for radial layout)
  • Range [0, 360] (non-inverted for RadialBarChart)
  • Numerical domain [0, 400]
  • Tick positions, labels, and scale

This significantly improves test coverage for the RadialBarChart scenario.


1772-1938: LGTM: Excellent test coverage for category type in RadialBarChart.

This new test suite validates:

  • Explicit type="category" overrides layout-based default
  • Categorical domain derived from data: [400, 300, 200, 278, 189]
  • Correct scale type: band
  • Tick offset behavior for category axes

Great addition for covering the category axis use case in radial layout.


2631-2631: LGTM: Implicit axis now includes evaluated type.

The test correctly verifies that implicit axes now have their type explicitly resolved to 'category' based on the RadarChart's centric layout. This validates the layout-based type inference feature.


2712-2715: Consistent with range inversion pattern.

This scale expectation uses the inverted range [-270, 90], consistent with the systematic change across all RadarChart tests. The domain and range expectations are coherent.


177-177: This concern is not a test issue.

The review comment conflates two different values being tested: selectAngleAxisRangeWithReversed (which returns [90, -270]) and selectPolarAxisScale's range property (which is [-270, 90]). The axis range configuration remains [90, -270], while the computed scale's range is [-270, 90]. This inversion in the scale computation is intentional behavior, not a systematic range change across test cases.

Likely an incorrect or invalid review comment.

src/state/selectors/polarAxisSelectors.ts (4)

10-10: LGTM: Imports support layout-based type resolution.

The new imports provide the necessary utilities for implementing layout-aware axis type inference:

  • AxisDomainTypeInput enables the "auto" type
  • selectPolarChartLayout provides layout context
  • getAxisTypeBasedOnLayout performs the type resolution logic

Also applies to: 15-16


18-34: LGTM: Type signature correctly supports AxisDomainTypeInput.

The type change to Omit<AngleAxisSettings, 'type'> & { type: AxisDomainTypeInput } is necessary to allow the type field to accept 'auto' in addition to 'number' and 'category'. While verbose, this ensures type safety.


54-77: LGTM: Layout-based type resolution is well-implemented.

The transformation of selectAngleAxis into a memoized selector with runtime type resolution is well-structured:

  • Proper use of createSelector for memoization
  • Layout-aware type evaluation via getAxisTypeBasedOnLayout
  • Fallback to 'category' when layout is undefined
  • Always returns a valid AngleAxisSettings object

The 'category' fallback is appropriate for angle axes in undefined layout contexts (e.g., RadarChart's centric layout).


79-95: LGTM: Radius axis follows same pattern as angle axis.

The selectRadiusAxis transformation mirrors the selectAngleAxis implementation:

  • Memoized with createSelector
  • Layout-aware type resolution
  • Consistent structure and logic

The 'category' fallback is only used when layout is undefined; otherwise, getAxisTypeBasedOnLayout correctly resolves the type based on whether the radius axis is categorical in the given layout.

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

@ckifer ckifer merged commit 57445bf into main Dec 26, 2025
40 of 44 checks passed
@ckifer ckifer deleted the axis-type-auto branch December 26, 2025 19:18
cloud-walker pushed a commit to cloud-walker/recharts that referenced this pull request Dec 28, 2025
…s#6823)

## Description

I have added new axis.type: "auto". This one sets the type to "category"
for categorical axes, and "number" for numeric axis.

Then I made the new "auto" the default for PolarAngleAxis and
PolarRadiusAxis. These two already had some smart-ish settings, where
they attempted to set the type by default, since 2.x or before. Too bad
that the smarts were not thorough, and the default axes didn't work. Now
they do! I consider this a bugfix, because the default axes were
completely broken before.

XAxis and YAxis too have `type="auto"` available but I left their
defaults. Vertical charts are viable (albeit a bit confusing) and so I
think new defaults here would be a breaking change. Let's do that in
4.0?

Also I added a little domain shape guard and these two together allowed
me to get rid of `checkDomainOfScale` so now we're not mutating the
scale once created which is nice.

## Related Issue

Weirdly enough I couldn't find anyone who complained about this but you
can see the improvement from the VR test.

Contributes a little to recharts#6645

## Motivation and Context

I expect that chart with implicit axes (i.e. without "PolarAngleAxis" in
JSX) and chart with default axes (i.e. with "<PolarAngleAxis />") should
be the same chart, with ticks and axisLine added.

## Types of changes

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

## Checklist:

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


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Axes gain an "auto" mode that infers number/category from chart
layout; polar layouts expose layout-aware hooks and utilities.

* **Improvements**
* Safer domain checking and more consistent axis-type evaluation;
defaults for polar axes changed to "auto"; corrected axis range
orientation across charts.

* **Documentation**
* API docs and story controls expanded to describe "auto" behavior and
scale/domain guidance.

* **Tests**
* Added and updated tests for auto inference, polar behavior, domain
checks, and adjusted scale expectations.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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