Skip to content

feat(charts): Once UI's own SVG chart renderer, recharts removed (3.0) - #378

Merged
lorant-one merged 18 commits into
feat/3-0-breaking-cleanupfrom
feat/3-0-chart-renderer
Nov 1, 2026
Merged

lorant-one merged 18 commits into
feat/3-0-breaking-cleanupfrom
feat/3-0-chart-renderer

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

Step 2 of the 3.0 chart plan (plan doc), for 3.0.0-beta.2 on 6 Nov. LineChart, BarChart, LineBarChart and PieChart now draw their own SVG, and their props stay the same as after #367.

What changes

  • Renderer: the new files are utils/scale.ts, CartesianPlot.tsx (shared by Line, Bar and LineBar), PiePlot.tsx and Chart.module.css. rechartsLoader.ts is deleted. The renderer places scales, stacks, d3's curves, ticks and bar slots the way recharts did.
  • Server HTML: the chart is in the first HTML, with no lazy chunk, no wait for document.fonts.ready, and no MissingDependency fallback. It draws at 640×320 until a ResizeObserver measures its container.
  • recharts removed from peerDependencies, the lockfile, the spec generator and the AI rules. MIGRATING §12 tells apps to uninstall it.
  • New in the browser:
    • The arrow keys, Home, End and Escape move the tooltip through the points.
    • Legend entries are buttons that hide or show a series or slice.
    • The entry animations follow prefers-reduced-motion.
  • Fixes:
    • The PieChart legend lists slices in data order with their own colours. recharts sorted them by name and coloured them by position, so an entry could show another slice's colour.
    • The LineBarChart legend now names the line first.
    • Pie gradients are scoped to each chart.
  • Docs: setup, quick-start, the map page, the curve and animation props, MIGRATING and CHANGELOG.

Bundle

The four charts' own code is 13.1 KB gzipped (38.6 KB minified, React external), plus 1.0 KB for Chart.module.css. recharts alone was 126 KB gzipped.

Checks

  • Core typecheck is clean, and core vitest passes 282 files and 3,941 tests, including the new chart-renderer.test.tsx (scales, curves, stacking, SSR, legend toggle, keyboard).
  • pnpm test:codemod 450/450, docs typecheck and check:docs clean. The Biome error baseline drops from 121 to 118.
  • 144 before/after screenshot pairs: every chart on the lineChart, barChart, lineBarChart, pieChart and setup pages, at 1280 and 390, in light and dark. Most differ by under 1% of pixels. The larger differences are the legend and gradient fixes above, plus the live streaming demos.

#377 (Sparkline and summaries) touches the same impl files. Whichever of the two merges second takes the other's change.



Generated by Claude Code

claude added 12 commits October 30, 2026 22:30
… horizontal bars (3.0)

Step 1 of the 3.0 chart plan: the props the renderer swap keeps.

- xKey names the x column (guessed before); series take label and format.
- valueFormat (compact, percent, Intl options or a function) and locale
  write the value axis and tooltip; without them charts draw as 2.x did.
  The value axis widens to fit its longest label.
- stack (true or "percent") on LineChart and BarChart; BarChart
  orientation="horizontal", with category labels sized to fit.
- C8: date.onChange becomes date.onRangeChange; the codemod renames it in
  an inline date and reports one built elsewhere.
- CurveType and ValueFormat types; curveType stays as a deprecated alias.
- Fixes: PieChart gradient ids are scoped to each chart; with no series
  the x column is no longer drawn as a series; ticks find their row in a
  map instead of scanning the data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
check-props lists inherited ChartProps rows on the mixin's table, so a
component page describing xKey, valueFormat or locale is reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The chart props now use CurveType (curveType stays as a deprecated
alias), so the regenerated spec resolves CurveType, not curveType.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
…line up with the title

A top-left legend was inset a fixed 80px, the old 64px axis plus 16, so a
wider value axis (currency) or the category column of horizontal bars put
it over the axis labels. Legend takes the axis width. Horizontal bars'
category names start 20px in, where the title does, in one column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
A DatePicker with no value showed this month, read from the clock while
rendering. A page prerendered in one month and opened in the next drew a
different month on the server and in the browser, and hydration failed
(React #418). The docs check visits pages 25 hours after the build, so
every PR's Docs build fails from 30 October 23:00 UTC to the end of the
31st.

Without a date, Calendar and the range calendars start on a fixed month,
hidden, and move to this month in an effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
LineChart, BarChart, LineBarChart and PieChart render through a shared
CartesianPlot and a PiePlot instead of recharts. Their props are unchanged.

- utils/scale.ts ports what the charts used from recharts and d3: nice and
  fixed-domain ticks, stacking (and percent stacking), bar slots, tick
  thinning, rounded bars, pie sectors and d3's curves.
- The chart is in the server HTML: one SVG with a viewBox, drawn at 640x320
  until a ResizeObserver measures the container. No lazy chunk, no
  fonts.ready wait, no MissingDependency fallback.
- Tooltip (DataTooltip), crosshair and band hover, arrow keys / Home / End /
  Escape through the points, legend entries are buttons that hide a series
  or slice, and the mount animations are CSS that prefers-reduced-motion
  turns off.
- Pie and LineBarChart legends list series in data order with their own
  colours; pie gradients are scoped per chart.
- recharts leaves peerDependencies, peerDependenciesMeta, the lockfile, the
  spec generator and the agent rules.
- The charts' own code is 13.1 KB gz (minified, React external) against
  recharts' 126 KB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The data setup page no longer asks for recharts, the curve and animation
props describe the new renderer with d3's curve names, MIGRATING tells
readers to uninstall recharts, and CHANGELOG [3.0.0] records the renderer
and the removed peer. The streaming example starts from deterministic
noise so its server and client HTML match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The renderer and the rebased base branch together leave two fewer Biome
errors than the recorded baseline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq

# Conflicts:
#	CHANGELOG.md
#	apps/docs/src/content/data/lineChart.mdx
#	packages/core/src/__tests__/legend.interaction.test.tsx
#	packages/core/src/modules/data/BarChart.impl.tsx
#	packages/core/src/modules/data/Legend.tsx
#	packages/core/src/modules/data/LineBarChart.impl.tsx
#	packages/core/src/modules/data/LineChart.impl.tsx
#	packages/core/src/modules/data/PieChart.impl.tsx

Copy link
Copy Markdown
Member Author

The visual check flagged four shots, and all four are intended. Three are on /data/setup: 676 px (0.28%) and two of about 40 px each. That is the new renderer drawing charts that had been drawn by recharts. The fourth is blocks_features tile05 at 390, 28 px (0.01%). I've added visual-change. The 144 before/after pairs I compared by hand for this PR differ by under 1% of pixels, apart from the pie and LineBarChart legend-colour fix described above.


Generated by Claude Code

#377's summaries meet the renderer here. The impl files keep the renderer
and hand their plot to ChartPlot; the wrappers wrap the impl in ChartA11y
directly, with no lazy import left to suspend.

The plot is now role="figure", not "img": the renderer put the legend's
toggle buttons and the keyboard-focusable plot inside it, and an image's
children are presentational (axe nested-interactive). The tests read the
drawn text apart from the hidden summary table, and render with the
LayoutProvider the tooltip needs now the SVG is in the first render.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The base re-sorted core's peers with maplibre-gl first and bumped recharts;
recharts stays removed. The curve and animation sections said the props were
Recharts' own; they now say what the renderer does with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The renderer's code is now inside ./data, where recharts (126 KB gzipped)
was an external peer the size gate never counted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq

Copy link
Copy Markdown
Member Author

"Build, typecheck and test" failed on 71a3ca3, but not because of this PR. All 4,034 tests passed. The run failed on one unhandled error: TypeError: win.removeEventListener is not a function at src/internal/sortable.ts:871. It comes from a setTimeout in sortable.test.tsx that fires after that file's jsdom window has been torn down. This PR doesn't touch Sortable, and the same tests passed on bd6340c an hour earlier. No fix exists yet. The timer could guard with win.removeEventListener?.(…) or be cleared on unmount; that belongs in its own PR rather than this one. I've re-run the job once.


Generated by Claude Code

@lorant-one
lorant-one merged commit 9e6c40c into feat/3-0-breaking-cleanup Nov 1, 2026
8 checks passed
@lorant-one
lorant-one deleted the feat/3-0-chart-renderer branch November 15, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants