Skip to content

Expose and document chart layout hooks and layout types in public API#7265

Merged
PavelVanecek merged 8 commits into
mainfrom
copilot/export-document-layout-hooks
Apr 24, 2026
Merged

Expose and document chart layout hooks and layout types in public API#7265
PavelVanecek merged 8 commits into
mainfrom
copilot/export-document-layout-hooks

Conversation

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Description

This updates the public API surface to include chart layout introspection hooks and their return types, and ensures they are documented/validated by omnidoc.
useChartLayout, useCartesianChartLayout, and usePolarChartLayout are exported from recharts, and now the related layout types are exported too: LayoutType, CartesianLayout, and PolarLayout.

  • Public API exports

    • Added exports in src/index.ts for:
      • useChartLayout
      • useCartesianChartLayout
      • usePolarChartLayout
    • Added type exports in src/index.ts for:
      • LayoutType
      • CartesianLayout
      • PolarLayout
  • Hook documentation source

    • Added/expanded JSDoc in src/context/chartLayoutContext.tsx for all three hooks so omnidoc can generate API pages with return semantics.
  • Tests

    • Extended test/context/chartLayoutContext.spec.tsx with focused coverage for:
      • outside-chart behavior (undefined)
      • cartesian chart layout behavior
      • polar chart layout behavior
    • Tests import hooks from ../../src to validate public export usage.
  • Docs wiring

    • Added the three hooks to API category mapping in www/src/docs/apiCates.ts.
    • Added API examples mapping entries in www/src/docs/apiExamples/index.tsx for:
      • useChartLayout, useCartesianChartLayout, usePolarChartLayout
      • LayoutType, CartesianLayout, PolarLayout
    • This satisfies omnidoc/example coverage and sitemap expectations.
// src/index.ts
export {
  useChartHeight,
  useChartWidth,
  useMargin,
  useChartLayout,
  useCartesianChartLayout,
  usePolarChartLayout,
} from './context/chartLayoutContext';

export type {
  CartesianLayout,
  PolarLayout,
  LayoutType,
  // ...
} from './util/types';

Related Issue

Export & document layout hooks:

  • useChartLayout
  • useCartesianChartLayout
  • usePolarChartLayout

Motivation and Context

These hooks already existed internally but were not part of the package entrypoint/docs surface. Once the hooks became public, their return types also needed to be publicly exported to keep the API complete and type-safe for consumers. This change makes both hooks and their related layout types first-class public API.

How Has This Been Tested?

  • Added targeted unit tests in test/context/chartLayoutContext.spec.tsx for public hook behavior across chart contexts.
  • Ran focused omnidoc/website validation paths impacted by new exports and docs mappings.
  • Ran:
    • npm run omnidoc
    • npm run test-omnidoc
    • npm run check-types-lib

Screenshots (if appropriate):

N/A (API/docs surface change)

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

Copilot AI linked an issue Apr 21, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add export and document layout hooks for charts Expose and document chart layout hooks in public API Apr 21, 2026
Copilot AI requested a review from PavelVanecek April 21, 2026 14:51
@PavelVanecek
PavelVanecek marked this pull request as ready for review April 23, 2026 13:41

@PavelVanecek PavelVanecek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also export the return types from index.ts as they are now part of the public API (LayoutType + CartesianLayout + PolarLayout). I believe that omnidoc should notify you of the same (npm run omnidoc && npm run test-omnidoc)

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.93103% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.08%. Comparing base (0f9fb4d) to head (5268b41).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
www/src/views/APIViewNew.tsx 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7265      +/-   ##
==========================================
+ Coverage   89.07%   89.08%   +0.01%     
==========================================
  Files         538      541       +3     
  Lines       41020    41069      +49     
  Branches     5563     5564       +1     
==========================================
+ Hits        36538    36586      +48     
- Misses       4474     4475       +1     
  Partials        8        8              

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

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Please also export the return types from index.ts as they are now part of the public API (LayoutType + CartesianLayout + PolarLayout). I believe that omnidoc should notify you of the same (`np...

Done in 4d77215. I exported LayoutType, CartesianLayout, and PolarLayout from src/index.ts, and ran npm run omnidoc + npm run test-omnidoc to verify the omnidoc expectations pass.

Copilot AI changed the title Expose and document chart layout hooks in public API Expose and document chart layout hooks and layout types in public API Apr 23, 2026
Copilot AI requested a review from PavelVanecek April 23, 2026 14:31
@github-actions

Copy link
Copy Markdown
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

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.3MB 1.55kB (0.12%) ⬆️
recharts/bundle-treeshaking-sankey 347.13kB 516 bytes (0.15%) ⬆️
recharts/bundle-treeshaking-sunburst 324.61kB 516 bytes (0.16%) ⬆️
recharts/bundle-es6 1.13MB 1.13kB (0.1%) ⬆️
recharts/bundle-umd 551.68kB 383 bytes (0.07%) ⬆️
recharts/bundle-treeshaking-cartesian 645.32kB 806 bytes (0.13%) ⬆️
recharts/bundle-treeshaking-polar 449.14kB 781 bytes (0.17%) ⬆️
recharts/bundle-treeshaking-treemap 357.74kB 516 bytes (0.14%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-treeshaking-sankey

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 516 bytes 347.13kB 0.15%
view changes for bundle: recharts/bundle-treeshaking-treemap

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 516 bytes 357.74kB 0.14%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 478 bytes 15.31kB 3.22%
context/chartLayoutContext.js 1.07kB 10.4kB 11.48% ⚠️
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 383 bytes 551.68kB 0.07%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
context/chartLayoutContext.js 1.07kB 9.06kB 13.4% ⚠️
index.js 62 bytes 3.93kB 1.6%
view changes for bundle: recharts/bundle-treeshaking-cartesian

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 806 bytes 645.32kB 0.13%
view changes for bundle: recharts/bundle-treeshaking-sunburst

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 516 bytes 324.61kB 0.16%
view changes for bundle: recharts/bundle-treeshaking-polar

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 781 bytes 449.14kB 0.17%

@github-actions

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
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.

@PavelVanecek
PavelVanecek merged commit d14c53b into main Apr 24, 2026
56 of 57 checks passed
@PavelVanecek
PavelVanecek deleted the copilot/export-document-layout-hooks branch April 24, 2026 14:00
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.

Export & document layout hooks

2 participants