feat(a2ui): add linechart#2680
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThis PR adds a complete LineChart component to the A2UI catalog. It includes the component implementation with three line variants (linear, natural, step), comprehensive styling, module exports, playground integration with a weather demo, and test coverage. ChangesLineChart Component Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui/src/catalog/LineChart/index.tsx`:
- Around line 161-170: The minMax function currently uses raw values and can
produce invalid bounds when entries are NaN/Infinity; update minMax to first
filter values to only Number.isFinite(v) items, then if the filtered array is
empty return the safe default {min: 0, max: 1}, otherwise compute min/max from
the filtered list; apply the same filtering/safe-default fix to the other
similar min/max calculation in the file (the other min/max helper around the
same area) to ensure non-finite series values do not produce broken SVG
coordinates.
- Around line 322-333: The axis tick rendering uses visibleLabelIndices and maps
labels into evenly spaced flex slots, causing ticks to drift from actual x
positions; change the tick layout so each tick is positioned according to its
original data index/relative x-position instead of equal flex slots—use the
original index-to-position mapping (the same scale or compute percent =
index/(dataLength-1)) and apply that as a positioning style on the elements
rendered in the LineChart (the loop using visibleLabelIndices, className
'line-chart-axis-tick') so ticks align with the plotted points; ensure you
reference the same labels and visibleLabelIndices values when computing
positions and handle edge cases like single-point charts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c66d0ea5-7e9b-46a4-a5c4-76bab2697a04
📒 Files selected for processing (11)
packages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/catalog/a2ui.tspackages/genui/a2ui-playground/src/demos.tspackages/genui/a2ui-playground/src/mock/basic/hangzhou-weather-trend.jsonpackages/genui/a2ui/package.jsonpackages/genui/a2ui/src/catalog/LineChart/index.tsxpackages/genui/a2ui/src/catalog/README.mdpackages/genui/a2ui/src/catalog/index.tspackages/genui/a2ui/src/index.tspackages/genui/a2ui/styles/catalog/LineChart.csspackages/genui/a2ui/test/catalog.test.ts
Merging this PR will improve performance by 17.36%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | transform 1000 view elements |
47 ms | 40 ms | +17.36% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing p/a2ui-linechart (348ef50) with main (e794bbf)
Footnotes
-
26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
React External#1625 Bundle Size — 697.99KiB (0%).348ef50(current) vs e794bbf main#1615(baseline) Bundle metrics
|
| Current #1625 |
Baseline #1615 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
41.22% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch p/a2ui-linechart Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1643 Bundle Size — 208.74KiB (0%).348ef50(current) vs e794bbf main#1633(baseline) Bundle metrics
|
| Current #1643 |
Baseline #1633 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
46.7% |
|
0 |
0 |
|
3 |
3 |
|
194 |
194 |
|
77 |
77 |
|
44.19% |
44.19% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1643 |
Baseline #1633 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
97.51KiB |
97.51KiB |
Bundle analysis report Branch p/a2ui-linechart Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#10084 Bundle Size — 903.53KiB (0%).348ef50(current) vs e794bbf main#10074(baseline) Bundle metrics
Bundle size by type
|
| Current #10084 |
Baseline #10074 |
|
|---|---|---|
499.15KiB |
499.15KiB |
|
402.16KiB |
402.16KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch p/a2ui-linechart Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#779 Bundle Size — 201.17KiB (0%).348ef50(current) vs e794bbf main#769(baseline) Bundle metrics
|
| Current #779 |
Baseline #769 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
28.74% |
|
0 |
0 |
|
4 |
4 |
|
97 |
97 |
|
30 |
30 |
|
39.41% |
39.41% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #779 |
Baseline #769 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
55.42KiB |
55.42KiB |
Bundle analysis report Branch p/a2ui-linechart Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8510 Bundle Size — 237.79KiB (0%).348ef50(current) vs e794bbf main#8500(baseline) Bundle metrics
|
| Current #8510 |
Baseline #8500 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
38.69% |
|
0 |
0 |
|
4 |
4 |
|
199 |
199 |
|
80 |
80 |
|
44.69% |
44.69% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8510 |
Baseline #8500 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
92.04KiB |
92.04KiB |
Bundle analysis report Branch p/a2ui-linechart Project dashboard
Generated by RelativeCI Documentation Report issue
Summary by CodeRabbit
LineChartcomponent to the A2UI catalog with configurable data series, axis labels, legend, grid display, and multiple interpolation variants.Checklist