Skip to content

Deprecate CartesianAxis, stop passing scale#6774

Merged
ckifer merged 1 commit intomainfrom
cartesianaxis-scale
Dec 15, 2025
Merged

Deprecate CartesianAxis, stop passing scale#6774
ckifer merged 1 commit intomainfrom
cartesianaxis-scale

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Dec 15, 2025

Description

I discovered that CartesianAxis never actually reads the scale prop. Also marked the whole component as deprecated - people should be using XAxis and YAxis instead.

Related Issue

#6645 - we don't want to expose the internal scale object in public API

#6734

Motivation and Context

I want to add more things to the internal scale representation but couldn't since it was used in CartesianAxis as public API. Turns out it's not used!

Summary by CodeRabbit

  • Documentation
    • Deprecated CartesianAxis component. Users are encouraged to use XAxis or YAxis for axis configuration instead. The component will become internal-only starting in Recharts v4.0.
    • Deprecated CartesianAxis scale property, which has been ignored since v3.0.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

This PR deprecates the CartesianAxis component and removes the scale prop from XAxis and YAxis. The scale prop type in CartesianAxisProps changes from RechartsScale to unknown, and deprecation notices are added indicating the component is internal-only and not intended for direct use.

Changes

Cohort / File(s) Summary
Deprecation & Type Updates
src/cartesian/CartesianAxis.tsx
Removed unused RechartsScale import; changed scale prop type from RechartsScale to unknown; added deprecation notice indicating scale prop is ignored since v3.0 and component is internal-only from v4.0
Scale Prop Removal
src/cartesian/XAxis.tsx, src/cartesian/YAxis.tsx
Removed scale state selection and eliminated scale prop passing to CartesianAxis; updated prop destructuring to drop scale handling in both components

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Consistent pattern of scale prop removal across multiple files
  • Straightforward deprecation annotations and import cleanup
  • Verify that scale removal does not impact rendering behavior in dependent components

Possibly related PRs

  • #6582 — Updates exported type signatures and cartesian axis component exports alongside these cartesian component modifications
  • #6553 — Modifies same cartesian axis components with related prop handling and Ticks restructuring
  • #6667 — Modifies CartesianAxis, XAxis, and YAxis implementations with prop defaults and handling

Suggested labels

typescript

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely summarizes the two main changes: deprecating CartesianAxis and stopping scale propagation, both evident in the changeset.
Description check ✅ Passed The description covers the main points (discovery of unused scale, deprecation) and related issues, but lacks details on testing approach and documentation updates required by the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 cartesianaxis-scale

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

🧹 Nitpick comments (3)
src/cartesian/XAxis.tsx (1)

130-131: Correctly swallowing scale before rendering; consider clearer alias naming

Removing scale (and scale from synchronizedSettings) before spreading into <CartesianAxis> is the right way to stop leaking the internal scale while keeping the public prop and store wiring intact. The early null-guards above also keep this safe when selectors return undefined.

As a minor readability tweak, consider renaming del / del2 to something like _unusedScaleProp / _unusedScaleState or adding a brief comment so it’s obvious they exist only to exclude scale from the spread.

src/cartesian/YAxis.tsx (1)

170-171: YAxis scale swallowing matches XAxis pattern; small naming nit

This mirrors the XAxis change and correctly keeps scale out of <CartesianAxis> while still honoring it in SetYAxisSettings, so the public API remains intact while the internal axis implementation stops exposing its scale.

As with XAxis, you might want to rename del / del2 to something like _unusedScaleProp / _unusedScaleState for self‑documentation.

src/cartesian/CartesianAxis.tsx (1)

75-79: scale prop deprecation and unknown typing look good; verify version note

Marking scale as deprecated and documenting that it’s ignored aligns with the PR goal of removing the scale from the public API surface, and switching the type to unknown avoids tying consumers to the internal RechartsScale shape, which is good for future refactors. As per coding guidelines, using unknown instead of any here is appropriate.

Please just double‑check that “ignored since 3.0” is historically accurate; if scale was still honored in any 3.x releases, it may be safer to either omit the version or tighten it to the exact minor where it stopped having effect.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25e24bb and c5aa207.

📒 Files selected for processing (3)
  • src/cartesian/CartesianAxis.tsx (2 hunks)
  • src/cartesian/XAxis.tsx (1 hunks)
  • src/cartesian/YAxis.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/cartesian/CartesianAxis.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/cartesian/CartesianAxis.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/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/cartesian/CartesianAxis.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:

  • src/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/cartesian/CartesianAxis.tsx
🧠 Learnings (5)
📓 Common learnings
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.
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, `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.
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
📚 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/cartesian/XAxis.tsx
  • src/cartesian/YAxis.tsx
  • src/cartesian/CartesianAxis.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/cartesian/CartesianAxis.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:

  • src/cartesian/CartesianAxis.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:

  • src/cartesian/CartesianAxis.tsx
⏰ 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 (1)
src/cartesian/CartesianAxis.tsx (1)

541-548: Clear deprecation messaging for CartesianAxis export

The deprecation JSDoc on the exported CartesianAxis—stating it’s not meant for direct app use, pointing users at XAxis/YAxis, and noting planned internalization in v4—is clear and consistent with the PR’s intent. This should help steer users away from depending on this internal component ahead of the breaking change.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.72%. Comparing base (25e24bb) to head (c5aa207).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6774      +/-   ##
==========================================
- Coverage   93.72%   93.72%   -0.01%     
==========================================
  Files         516      516              
  Lines       43401    43397       -4     
  Branches     5008     5006       -2     
==========================================
- Hits        40678    40674       -4     
  Misses       2717     2717              
  Partials        6        6              

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

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

@github-actions
Copy link
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

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

@ckifer ckifer merged commit 71670d3 into main Dec 15, 2025
39 checks passed
@PavelVanecek PavelVanecek deleted the cartesianaxis-scale branch December 15, 2025 06:12
@codecov
Copy link

codecov bot commented Dec 15, 2025

Bundle Report

Changes will increase total bundle size by 74 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.17MB 21 bytes (0.0%) ⬆️
recharts/bundle-es6 1.01MB 51 bytes (0.01%) ⬆️
recharts/bundle-umd 521.92kB 2 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/CartesianAxis.js 199 bytes 17.1kB 1.18%
cartesian/YAxis.js -89 bytes 8.88kB -0.99%
cartesian/XAxis.js -89 bytes 7.43kB -1.18%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/CartesianAxis.js 199 bytes 15.84kB 1.27%
cartesian/YAxis.js -74 bytes 7.51kB -0.98%
cartesian/XAxis.js -74 bytes 6.11kB -1.2%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 2 bytes 521.92kB 0.0%

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