These docs follow unreleased main. The latest published TanStack Charts release is 0.7.0; it is pre-alpha and its API may change between releases.
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 use compact scales to define common numeric and categorical axes. 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 scale and algorithm boundaries, responsive scene compilation, and framework lifecycle.
The library is designed for two equally important authors:
The same definition can feed the vanilla DOM host and framework adapters. React and Octane also provide optional Canvas entries; the experimental React Native adapter consumes definitions from the universal entry.
import { defineChart, differenceY, window } from '@tanstack/charts'
import { scaleLinear } from '@tanstack/charts-scales/linear'
import { scaleUtc } from 'd3-scale'
interface ClosingPrice {
Date: Date
Close: number
}
const observations: readonly ClosingPrice[] = [
{ Date: new Date('2013-05-13T00:00:00Z'), Close: 64.96 },
{ Date: new Date('2013-05-14T00:00:00Z'), Close: 63.41 },
{ Date: new Date('2013-05-15T00:00:00Z'), Close: 61.26 },
{ Date: new Date('2013-05-16T00:00:00Z'), Close: 62.08 },
{ Date: new Date('2013-05-17T00:00:00Z'), Close: 61.89 },
{ Date: new Date('2013-05-20T00:00:00Z'), Close: 63.28 },
{ Date: new Date('2013-05-21T00:00:00Z'), Close: 62.81 },
{ Date: new Date('2013-05-22T00:00:00Z'), Close: 63.05 },
]
const rows = window(observations, {
size: 3,
orderBy: 'Date',
anchor: 'end',
partial: false,
outputs: {
average: { value: 'Close', reduce: 'mean' },
},
})
const closingPriceChart = defineChart({
marks: [
differenceY(rows, {
x: 'Date',
y1: 'average',
y2: 'Close',
positiveFill: '#16a34a',
negativeFill: '#dc2626',
stroke: '#166534',
comparisonStroke: '#475569',
}),
],
x: {
scale: scaleUtc,
nice: true,
axis: { label: 'Date' },
},
y: {
scale: scaleLinear,
nice: true,
grid: true,
axis: { label: 'Close (USD)' },
},
})The rolling average is an ordinary, visible window transform. differenceY owns sign segmentation and exact crossing interpolation. The y axis uses the compact numeric scale; the calendar-aware x axis upgrades only that mapping to D3's scaleUtc. Installation lists the exact packages, and Scales explains the ownership boundary.
TanStack Charts owns the parts that make a declarative chart reliable inside an application:
TanStack Charts keeps data preparation explicit and optional algorithms behind narrow imports.
| Responsibility | Owner |
|---|---|
| Common numeric and categorical scale mappings | @tanstack/charts-scales |
| Common group, bin, window, normalize, select, and row-stack transforms | TanStack's eager data-transform helpers |
| Temporal, nonlinear, piecewise, spatial, and other specialized algorithms | Exact TanStack entries, granular D3 modules, or application code |
| Fetching, cleaning, profiling, and exploratory analysis | Your data layer, server, or AI workflow |
| Mark-channel domain inference, responsive ranges, guide layout, scenes, rendering, and chart lifecycle | TanStack Charts |
| Page controls, queries, filters, persistence, memoization, and application state | Your application |
Prepared data can come from TanStack transforms, 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/charts-scales | Compact linear, band, point, and ordinal scales |
| @tanstack/react-charts | React <Chart> |
| @tanstack/react-native-charts | Experimental React Native SVG <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.