Skip to content

docs: add ErrorBar dataPointFormatter storybook examples#7026

Merged
PavelVanecek merged 2 commits intorecharts:mainfrom
mixelburg:fix/errorbar-datapointformatter-story
Feb 20, 2026
Merged

docs: add ErrorBar dataPointFormatter storybook examples#7026
PavelVanecek merged 2 commits intorecharts:mainfrom
mixelburg:fix/errorbar-datapointformatter-story

Conversation

@mixelburg
Copy link
Contributor

@mixelburg mixelburg commented Feb 18, 2026

Fixes #3609

Adds storybook stories demonstrating ErrorBar usage across different chart types (ScatterChart, BarChart, LineChart), illustrating how each chart type's internal dataPointFormatter extracts position and error values differently.

Stories added:

  • InScatterChart — ErrorBar with both X and Y error bars in a ScatterChart
  • InBarChart — ErrorBar showing asymmetric error values in a BarChart
  • InLineChart — ErrorBar on a LineChart with custom error data

Summary by CodeRabbit

  • Documentation
    • Added Storybook examples showing ErrorBar usage in ScatterChart, BarChart, and LineChart.
    • Includes sample datasets demonstrating error values for both X and Y directions.
    • Examples illustrate how charts consume data to position points and render error bars, including notes on data-point formatting for error extraction.

Add stories demonstrating ErrorBar usage across ScatterChart, BarChart,
and LineChart to illustrate how each chart type's dataPointFormatter
extracts position and error values differently.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Walkthrough

Adds a new Storybook story module ErrorBarDataPointFormatter.stories.tsx demonstrating ErrorBar usage in ScatterChart, BarChart, and LineChart with example data arrays and three exported stories (InScatterChart, InBarChart, InLineChart).

Changes

Cohort / File(s) Summary
Storybook ErrorBar Story
storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx
New story file with default export metadata, two data sets (scatterData, barAndLineData), and three exported stories rendering ErrorBar in ScatterChart (errorX/errorY), BarChart (uvError), and LineChart (uvError).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding Storybook examples for ErrorBar's dataPointFormatter usage across chart types.
Description check ✅ Passed The description adequately explains the purpose, linked issue, and specific stories added, though it deviates from the template by not using all standard sections.
Linked Issues check ✅ Passed The PR fulfills issue #3609 by providing Storybook examples demonstrating ErrorBar's dataPointFormatter usage across different chart types as requested.
Out of Scope Changes check ✅ Passed All changes are scoped to the ErrorBar documentation objective: new story file and examples demonstrating dataPointFormatter across chart types, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx`:
- Around line 17-23: The exported default CSF meta object for the story (the
object with title: 'Examples/cartesian/ErrorBar/DataPointFormatter' and
component: ErrorBar) contains a dead property docs: { autodocs: false } which is
ignored in Storybook v9; remove the docs: { autodocs: false } entry from the
default export so the meta only includes title and component (and any valid
parameters/tags if needed), and apply the same removal pattern to other story
files that include docs: { autodocs: false }.
- Around line 2-15: Replace the internal '../../../../src' import with the
public package entry point 'recharts' for the listed components (BarChart, Bar,
LineChart, Line, ScatterChart, Scatter, ErrorBar, CartesianGrid, XAxis, YAxis,
Tooltip, ResponsiveContainer) so the story imports from 'recharts' rather than
the internal src path; update the import statement to reference 'recharts' and
ensure all referenced symbols remain the same.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx`:
- Around line 40-48: Update the doc comment for the ErrorBarDataPointFormatter
story to correct the misleading phrase about where error magnitudes come from:
change the ScatterChart line so it states that ScatterChart uses `cx`/`cy` for
rendered positions (computed from `node.x`/`node.y`) and that error values are
read from the `ErrorBar`'s `dataKey` (e.g., `errorY`/`errorX` fields in the
data), referencing `ScatterChart`, `cx`/`cy`, `node.x`/`node.y`, and
`ErrorBar`/`dataKey`/`errorY`/`errorX` so readers can locate the relevant
concepts.

---

Duplicate comments:
In `@storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx`:
- Around line 1-20: No changes required — the story now correctly imports from
the public 'recharts' entry and the exported meta object (default export
containing title and component: ErrorBar) is clean with the removed docs: {
autodocs: false } config; simply leave ErrorBarDataPointFormatter.stories.tsx
as-is (keep the imports: BarChart, Bar, LineChart, Line, ScatterChart, Scatter,
ErrorBar, CartesianGrid, XAxis, YAxis, Tooltip, ResponsiveContainer and the
default export with title 'Examples/cartesian/ErrorBar/DataPointFormatter' and
component: ErrorBar).

Comment on lines +40 to +48
/**
* Each chart type (Scatter, Bar, Line) uses its own internal `dataPointFormatter`
* to extract the position and error values from its data points. This story shows
* ErrorBar working across all three chart types to illustrate these differences.
*
* - **ScatterChart**: uses `cx`/`cy` for position and reads error from `node.x`/`node.y`
* - **BarChart**: uses bar rectangle coordinates and reads error from the bar value
* - **LineChart**: uses line point coordinates and reads error from the point value
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Misleading phrase in the doc comment — node.x/node.y are position coordinates, not error sources.

Line 45 says ScatterChart "reads error from node.x/node.y", but that's incorrect. The error values are always read from the dataKey prop on ErrorBar (i.e., errorY/errorX fields in the data). node.x/node.y are the coordinate values used to compute the rendered position (cx/cy), not the error magnitudes.

📝 Suggested correction
- * - **ScatterChart**: uses `cx`/`cy` for position and reads error from `node.x`/`node.y`
- * - **BarChart**: uses bar rectangle coordinates and reads error from the bar value
- * - **LineChart**: uses line point coordinates and reads error from the point value
+ * - **ScatterChart**: position derived from `cx`/`cy` pixel coordinates; error magnitude read via `dataKey` (e.g. `errorY`, `errorX`)
+ * - **BarChart**: position derived from bar rectangle boundaries; error magnitude read via `dataKey` (e.g. `uvError`)
+ * - **LineChart**: position derived from line-point coordinates; error magnitude read via `dataKey` (e.g. `uvError`)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Each chart type (Scatter, Bar, Line) uses its own internal `dataPointFormatter`
* to extract the position and error values from its data points. This story shows
* ErrorBar working across all three chart types to illustrate these differences.
*
* - **ScatterChart**: uses `cx`/`cy` for position and reads error from `node.x`/`node.y`
* - **BarChart**: uses bar rectangle coordinates and reads error from the bar value
* - **LineChart**: uses line point coordinates and reads error from the point value
*/
/**
* Each chart type (Scatter, Bar, Line) uses its own internal `dataPointFormatter`
* to extract the position and error values from its data points. This story shows
* ErrorBar working across all three chart types to illustrate these differences.
*
* - **ScatterChart**: position derived from `cx`/`cy` pixel coordinates; error magnitude read via `dataKey` (e.g. `errorY`, `errorX`)
* - **BarChart**: position derived from bar rectangle boundaries; error magnitude read via `dataKey` (e.g. `uvError`)
* - **LineChart**: position derived from line-point coordinates; error magnitude read via `dataKey` (e.g. `uvError`)
*/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx`
around lines 40 - 48, Update the doc comment for the ErrorBarDataPointFormatter
story to correct the misleading phrase about where error magnitudes come from:
change the ScatterChart line so it states that ScatterChart uses `cx`/`cy` for
rendered positions (computed from `node.x`/`node.y`) and that error values are
read from the `ErrorBar`'s `dataKey` (e.g., `errorY`/`errorX` fields in the
data), referencing `ScatterChart`, `cx`/`cy`, `node.x`/`node.y`, and
`ErrorBar`/`dataKey`/`errorY`/`errorX` so readers can locate the relevant
concepts.

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (c3b308c) to head (9f954d7).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7026   +/-   ##
=======================================
  Coverage   90.12%   90.12%           
=======================================
  Files         526      526           
  Lines       39183    39183           
  Branches     5423     5423           
=======================================
  Hits        35312    35312           
  Misses       3862     3862           
  Partials        9        9           

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

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

@PavelVanecek PavelVanecek merged commit 74be311 into recharts:main Feb 20, 2026
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storybook: ErrorBar - Add Example for using the dataPointFormatter

2 participants