TanStack Charts
Use this skill when work touches TanStack Charts, especially mark composition, transforms, compact vs D3 scales, React Chart, SSR, tooltips/focus, Canvas, optional motion(), React Native, spatial/hierarchy/network entries, or migrations.
Treat the library as pre-alpha (0.14.0 at skill refresh). Official docs say it is not ready for production use. Verify current docs and the npm latest version before relying on edge APIs. Prefer official docs / GitHub tag v0.14.0 over stale search or archived react-charts.
Workflow
- Confirm the stack is the new TanStack Charts on the unified package:
- Correct:
bun add @tanstack/chartsplus framework peers. ImportChartfrom@tanstack/charts/react, scales from@tanstack/charts/scales/linear(and/band,/point,/ordinal). - Compatibility only:
@tanstack/react-charts,@tanstack/charts-scales, and other@tanstack/*-chartsadapter packages still exist for existing apps. Do not add them to new code. - Wrong: unscoped
react-charts, oroptions/primaryAxis/secondaryAxes/UserSerie.
- Correct:
- Refresh versions and URLs from source-map.md.
- Installation,
defineChart, scales, axes, tooltip extensions: setup-core.md. - Marks,
decorative, polar/geo, composites: marks-composition.md. - Eager transforms vs mark layout: transforms-layouts.md.
- Adapters, sizing, focus, crosshair, brush/zoom/cursor/selection, motion, SSR: frameworks-interaction.md.
- Testing, large data, Canvas, custom marks, AI checks, migrations: production-patterns.md.
Implementation Judgment
- A chart is a composition of marks, not a chart-type component. Prefer the smallest mark set that answers the question.
- Keep rows in their natural shape. Do not invent a library-owned series wrapper.
- Install one package:
@tanstack/charts. Compact scales: exact@tanstack/charts/scales/*(no/scalesbarrel). Import and declare everyd3-*the application source uses. Pass factories for inferred domains, or configured instances for fixed domains. Never assign pixel ranges to positional scales the chart owns. - Both positional scales are required when marks materialize those dimensions.
- Axis presentation lives under
axis/axis.ticks/axis.tickLabels.axis: falsehides a guide and keeps the scale. Set the axis tonullonly when no mark uses that dimension. - Memoize the complete
defineChart(...)against every captured value. Definition identity is the update boundary. Responsive{ chart: ({ width }) => …, svgAnimation, tooltip, … }retains outer options. - Default SVG animation option is
svgAnimation, notanimate.motion()ignoressvgAnimationand reads definition-levelmotion. - Bars/areas with a single length channel stack implicitly. Use
layout: group()for side-by-side bars;layout: stack({ order, offset })only when order/offset must be explicit;y1/y2orx1/x2opts out. - Native tooltips:
tooltipfrom@tanstack/charts/tooltip. Escape clipping withportalfrom@tanstack/charts/tooltip/portal. ReactrenderTooltipBodyrequires@tanstack/charts/react/tooltip. Grouped rows default to visual mark order. - Channel and transform accessors use
(datum, { index, data }), not(datum, index, data). - Rolling transforms:
rollingWindow, notwindow. Reducer helper:delta, notdifference. - Supply
ariaLabelon every mounted chart. Usefocus: falseto omit generated focus geometry;focusRing: falsewhen authored focus marks replace the ring;focusDisabledwhen an app gesture owns the surface. Radial grouped focus:focusGroupAnglefrom@tanstack/charts/polar. - Default to SVG. Import polar, geo, Canvas, export, motion, spatial, hierarchy, network, brush/zoom only through exact subpaths.
- Prefer built-in marks (
boxY,waffleY,violinY, composites) beforecreateMark. Wrap a sibling layer withdecorative(...)when only one layer should own hit-testing.
Verification
Prefer the repo's existing checks. For meaningful Charts work, include the relevant subset:
- Package check:
@tanstack/chartson0.14.x(or the project's pin). New code imports adapters/scales from that package, not@tanstack/react-charts/@tanstack/charts-scales. - Typecheck for channels, scales, axis options, tooltip host brands, motion,
ChartPointcallbacks—no unexpected casts. createChartScene/renderChartSvgfor domains, geometry, keys, a11y markup.- Interaction tests: focus, keyboard, tooltip, selection, brush/zoom, resize, empty data, destroy.
- Light/dark smoke when theme tokens or tooltip surface CSS change.
- SSR/hydration smoke for
initialWidth, formatters, Canvas shells,idPrefix. - Bundle measurement when adding polar, geo, Canvas, export, motion, spatial, hierarchy, network, or extra D3 modules.