TanStack Charts is a small, framework-agnostic chart grammar for TypeScript and JavaScript. Give each mark its natural data, map fields or accessors to visual channels, and supply the D3 scales that define the meaning of each axis. TanStack Charts compiles that declaration into a responsive, keyed scene and renders accessible SVG by default, with Canvas available as an opt-in surface.
TanStack Charts builds on the grammar-of-graphics tradition established by Leland Wilkinson and developed through projects such as ggplot2, Vega-Lite, and Observable Plot. Observable Plot is the closest API influence for mark-local data, channels, and layered composition. TanStack Charts applies those ideas to typed application infrastructure with explicit D3 primitives, responsive scene compilation, and framework lifecycle.
The library is designed for two equally important authors:
The same definition works with the vanilla DOM host and every framework adapter. React and Octane also provide optional Canvas entries.
import { scaleLinear, scaleUtc } from 'd3-scale'
import { areaY, defineChart, lineY, ruleY } from '@tanstack/charts'
const rows = [
{ id: 'jan', date: new Date('2026-01-01T00:00:00Z'), actual: 42, target: 38 },
{ id: 'feb', date: new Date('2026-02-01T00:00:00Z'), actual: 31, target: 35 },
{ id: 'mar', date: new Date('2026-03-01T00:00:00Z'), actual: 48, target: 44 },
{ id: 'apr', date: new Date('2026-04-01T00:00:00Z'), actual: 39, target: 46 },
]
const performanceChart = defineChart({
marks: [
ruleY([40], { stroke: '#94a3b8', strokeOpacity: 0.7 }),
areaY(rows, {
x: 'date',
y1: 'target',
y2: 'actual',
key: 'id',
fill: '#2563eb',
fillOpacity: 0.18,
}),
lineY(rows, {
x: 'date',
y: 'actual',
key: 'id',
stroke: '#2563eb',
}),
],
x: {
scale: scaleUtc,
nice: true,
label: 'Month',
},
y: {
scale: scaleLinear().domain([0, 50]).nice(),
label: 'Score',
grid: true,
},
})The direct d3-scale imports in this example are application dependencies. Install d3-scale and @types/d3-scale alongside TanStack Charts. Installation lists the exact packages, and Scales and D3 explains the ownership boundary.
TanStack Charts owns the parts that make a declarative chart reliable inside an application:
TanStack Charts deliberately does not hide data or spatial algorithms behind a second abstraction.
| Responsibility | Owner |
|---|---|
| Scale domains, scale semantics, binning, stacking, grouping, interpolation, and spatial algorithms | Your application using the granular D3 modules it needs |
| Fetching, cleaning, profiling, and exploratory analysis | Your data layer, server, or AI workflow |
| Marks, channels, responsive ranges, guide layout, scenes, rendering, and chart lifecycle | TanStack Charts |
| Page controls, queries, filters, persistence, and application state | Your application |
This division keeps the core small and makes advanced work explicit. Prepared data can come from D3, SQL, a server, or ordinary TypeScript; marks consume it without requiring a special series container.
The normal path is intentionally short:
Every automatic behavior has an explicit escape hatch. The Guides cover those controls by task rather than repeating the API reference.
| Package | Use it for |
|---|---|
| @tanstack/charts | Definitions, marks, scenes, SVG, Canvas, export, and vanilla DOM |
| @tanstack/react-charts | React <Chart> |
| @tanstack/preact-charts | Preact <Chart> |
| @tanstack/vue-charts | Vue <Chart> |
| @tanstack/solid-charts | Solid <Chart> |
| @tanstack/svelte-charts | Svelte <Chart> |
| @tanstack/angular-charts | Angular <tanstack-chart> |
| @tanstack/lit-charts | Lit <tanstack-chart> |
| @tanstack/alpine-charts | Alpine x-chart |
| @tanstack/octane-charts | Octane <Chart> |
All packages are ESM and tree-shakeable. Built-in marks and optional capabilities also have subpath exports when a library or design system needs tighter bundle boundaries.