docs: add ErrorBar dataPointFormatter storybook examples#7026
docs: add ErrorBar dataPointFormatter storybook examples#7026PavelVanecek merged 2 commits intorecharts:mainfrom
Conversation
Add stories demonstrating ErrorBar usage across ScatterChart, BarChart, and LineChart to illustrate how each chart type's dataPointFormatter extracts position and error values differently.
WalkthroughAdds a new Storybook story module Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx
Outdated
Show resolved
Hide resolved
storybook/stories/Examples/cartesian/ErrorBarDataPointFormatter.stories.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
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).
| /** | ||
| * 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 | ||
| */ |
There was a problem hiding this comment.
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.
| /** | |
| * 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Fixes #3609
Adds storybook stories demonstrating ErrorBar usage across different chart types (ScatterChart, BarChart, LineChart), illustrating how each chart type's internal
dataPointFormatterextracts position and error values differently.Stories added:
Summary by CodeRabbit