ztd-charts
v0.13.1
Published
47 animated, interactive React charts in pure SVG with zero runtime dependencies, a JSON spec, and CLI and MCP tools for AI agents
Maintainers
Readme
ztd charts
Animated, accessible React charts that read like a report. 47 charts in pure SVG with no runtime dependencies, and a JSON spec your AI agent can write.
Website · Gallery · Docs · Example dashboards · GitHub · 한국어

Why ztd charts
- Each card says one thing. One item takes the accent color and the rest stay neutral, with a bold takeaway under the chart, so a reader sees the point before reading the axes.
- Motion that explains. Charts draw in as they scroll into view, move on from where they are when the data changes, and let you drag over a range to read its change, high and low.
- Accessible by default. Keyboard navigation, a screen reader description and data table for every chart, reduced motion, and every label at WCAG AA contrast.
- Small, with nothing else to install. React is the only peer dependency. A chart with the shared core is about 12 to 26 kB Brotli, and very large data switches to canvas on its own.
- Ready for AI. Every chart is also a JSON spec with a public JSON Schema, and a CLI, an MCP server and an agent skill validate it and render it to PNG, SVG or HTML.
- English and Korean. en-US by default.
locale="ko-KR"switches number formats (1.2만, 3.4억) and chart text to Korean.

Quick start
npm i ztd-chartsimport { ChartCard, PieChart } from "ztd-charts";
const sales = [
{ device: "Mobile", share: 72 },
{ device: "Desktop", share: 23 },
{ device: "Tablet", share: 5 },
];
export function SalesByDevice() {
return (
<ChartCard title="Sales by device" subtitle="Share of revenue (%)" takeaway="Mobile brings in most sales">
<PieChart data={sales} label="device" value="share" highlight="Mobile" />
</ChartCard>
);
}Every chart page in the gallery has the React code, the JSON spec and the CLI command for that chart.
What's in the package
ztd-charts: 47 chart components (new in 0.13.0:SparkTable,CohortChartandHorizonChart),LiveLineChart,ChartCard,ChartGrid,ChartFacets,StatCard,ThemeProvider,registerMapand the data helpers.ztd-charts/spec: the chart registry, JSON Schema, spec validation and chart suggestions, without React.FACET_TYPESandFACET_MAXsay which charts takefacetand how many panels it draws.ztd-charts/server: server rendering to SVG and HTML, with every built-in map already registered.ztd-charts/geo/world,ztd-charts/geo/us-statesandztd-charts/geo/kr-sido: map boundaries, one entry point per map, so a page that draws no map loads none.ztd-charts/schema.json: the JSON Schema for chart specs.
New in 0.13.1: fixes. In ChartCard and renderSpecToSVG, a takeaway that does not fit on one line beside the level badge and the sample note now takes the full card width in balanced lines, and the badge row moves below it on the right. Before, a narrow browser card squeezed the takeaway into the room left of the badges (as narrow as 82px, up to 7 lines) and the server SVG drew it under them. Wide cards look as before. When shortened tick labels collide, percent, ratio, currency and object formats such as { suffix: "ms" } now keep their format with more decimals instead of switching to plain numbers (a ratio axis read 0.102 to 0.108 beside 10.8% value labels). On a short horizontal Tree, a highlighted leaf name that would cover another name is left out, and its accent link and dot stay. On narrow cards, ParallelCoordinates and BumpChart give the highlighted line's end name more room, so it is no longer cut. Chart suggestions (suggestCharts, ztd-charts suggest and the MCP suggest_chart tool) no longer put the chart type's description in card.takeaway. Ten gallery examples, which get_chart_schema returns to agents as model specs, now state a conclusion from their own data (pie: "Mobile makes 72% of sales"), and the schema describes card.takeaway as the card's conclusion in one short sentence, not a description of the chart type. The syncId and area maxPoints descriptions are corrected.
New in 0.13.0: three charts. SparkTable puts one metric per row with its trend, latest value, change and target, each row on its own scale, so revenue, users and rates share one table; the change pill takes the accent only for a move in the good direction (better: "down" for churn or latency, or per row through metrics). CohortChart is a retention table: one row per signup cohort and one column per period since it started, each cell colored by the share still active. The first period, where everyone is still there, is gray and left out of the color scale, and the average row on top weighs each cohort by its size. HorizonChart fits 13 to 60 time series on one card in thin rows, folding each value into one to three color bands of the same size; values below the baseline mirror into the row in gray, and the legend on top gives each band's range. New spec aliases: kpiTable, metricTable, sparklineTable, retention, cohortTable, retentionTable, horizonChart and horizonGraph.
New in 0.12.0: five options, each with its own variant in the gallery. variant: "raincloud" on BoxPlot draws each group as a half density curve, a thin box and every sample as a dot. hull on ScatterChart outlines each series with a rounded shape in its color, under the dots. dimensions on SankeyChart (encoding.dimensions in a spec) reads a wide table where each row is one path through 2 to 6 stage columns, so no link rows are needed. flow: "right" on FunnelChart runs the stages from left to right for low, wide cards. centerLabels on BarChart puts the row names of diverging horizontal bars in a column at the zero line, as in a population pyramid. New spec aliases: raincloud, alluvial, parallelSets, butterfly, pyramid and populationPyramid.
New in 0.11.3: on a wide FlowMap, flows that cross the map edge now stop at the edge of the chart. They were clipped to the globe's outline, which lies outside the svg when the map is fitted to its places (about 21px past it in the example at 1200px wide), so their ends and arrowheads drew into the card padding. The comments in the sources and the JSDoc in the type definitions are now in English, so editors show English hover text.
New in 0.11.2: the period label behind a BarRace (the large year or date) now meets WCAG AA contrast on the card, instead of 1.55:1 in dark and 1.33:1 in light. It uses the theme's ink at the lowest opacity that reaches the minimum for its size: 3:1 for large text (36% in dark, 47% in light), and 4.5:1 when a narrow chart draws it below 18.66px (48% and 60%). It stays quiet behind the bars, and a custom theme gets its own opacity from its ink and panel colors.
New in 0.11.1: the Skyline example shows the last 7 days instead of 14, so each day keeps its own block and date in a gallery card, and the Timeline example shows the status strip with a status legend. The timeline variant "Status strip" is now "Status colors on bars" (status-bars), which colors the bars by status without the strip.
New in 0.11.0: statusStrip on Timeline (options.statusStrip in a spec) adds the status strip as the bottom row. Consecutive items with the same status join into one labelled segment in the legend's status colors, and pointing at the strip picks the item that set the state there. The bars then show durations, with the longest in the accent. It is off by default, and the "Status strip" variant now shows this form.
New in 0.10.0: two more theme colors, accent2 (pink) and accent3 (the other theme's accent: lime in light, sky in dark), each at least 3:1 against the card and neutralSoft. SkylineChart paints its front row with them in the high view and splits the top of each tile by series share, so failures and retries stay readable on days when they are only a pixel tall. Highlighting a front series and the low view keep the 0.9 colors. A theme given as a partial object takes the two colors from its base; a full ChartTheme written by hand needs the two new fields.
New in 0.9.0: SkylineChart looks down on its floor by default (view: "high"), so the smaller outcome in front (failures, retries) reads as a row of tiles even on days when it is only a few pixels tall. Periods stay on a level axis, so a taller block always means more. view: "low" keeps the 0.8 look, which leaves more room for the value scale. depth runs from 0.1 to 0.45 in the high view (default 0.42) and from 0.1 to 0.32 in the low view (default 0.32).
Data helpers: useChartData loads a URL or an async function and reports loading, error and empty states. parseCSV, fromRows, fromObjects and melt reshape tables. percentiles(rows, { by: "minute", value: "ms" }) turns raw samples into p50, p95 and p99 rows for a latency chart.
Card and tooltip helpers: DownloadButtons adds CSV, SVG and PNG download buttons to a card, and templateTooltip("{label} · {value} · {owner}") shows other columns of the row in the tooltip.
Diverging bars: layout: "diverging" on BarChart stacks the negative series left of a zero line and the rest to the right, for Likert surveys, for-and-against splits and population pyramids. neutral splits one series across the line, and percent shows each segment as a share of its row.
Maps: Choropleth shades regions by value, SymbolMap puts a circle sized by value at each place, and FlowMap draws curved arrows from place to place. map defaults to "auto", which picks the registered map that matches the most regions in your data: world (ISO codes or country names), us-states or kr-sido. A map object or your own GeoJSON FeatureCollection works too. In the browser, register the maps you draw:
import { Choropleth, registerMap } from "ztd-charts";
import { world } from "ztd-charts/geo/world";
registerMap(world);
const users = [
{ country: "BRA", users: 412 },
{ country: "DEU", users: 268 },
{ country: "IND", users: 530 },
{ country: "USA", users: 655 },
];
export const UsersByCountry = () => <Choropleth data={users} region="country" value="users" />;ztd-charts/server, the CLI and the MCP server draw "map": "world" with no setup. focus: "europe" crops the world map, and center: "pacific" on the symbol and flow maps puts the Pacific in the middle, so Shanghai to Los Angeles draws as one line. FlowMap reads the same source, target and value rows as SankeyChart, with places as region names or places: { Shanghai: [121.5, 31.2] }. The boundary data adds about 25 kB Brotli for the world, 11 kB for the US and 5 kB for Korea; its sources and licences are in NOTICE.md.
Tile grid map: TileMap draws one equal tile per region, shaded by its value, so Rhode Island reads as large as Texas. It ships the 50 US states and DC (us-states), Korea's 16 regions from July 2026 (kr-sido) and the 17 before the merger (kr-sido-2025), picks one from the data with "auto", or takes your own tiles; resolveGrid, tileMatcher, tileNeighbor and TILE_MAPS expose the grids and name matching.
More new charts: Tree draws a hierarchy as linked dots, horizontal or radial, from nested rows or id and parent columns. Timeline draws one bar per item from start to end, for schedules, job runs and incidents. NetworkChart shows who connects to whom as arcs over one line, from the same rows as the sankey. BarRace steps through time with the top bars re-sorting at each step, with play, pause and a frame slider. stratify, networkGraph, readTimeline, timelineRows and formatDuration expose their layouts and the duration format.
New options: shape: "arc" on WaffleChart draws a seat chart in half-circle rows, one dot per seat, with total for empty seats and referenceLines for a majority. bin: "hex" on ScatterChart counts dense points into hexagons shaded by count, for 100,000 points and more.
Size limits: a spec's width and height are at most 10,000 px (MAX_CHART_SIZE in ztd-charts/spec). validateSpec rejects more, and server rendering clamps sizes that skip validation, so a spec cannot make a server allocate without limit.
Small multiples: facet: { by: "region" } on a line, area, bar or scatter spec draws the same chart once per group on a shared scale, and <ChartFacets> does the same in React. Each component has a matching props type (ChoroplethProps, TileMapProps, ChartFacetsProps and so on), and GeoMap, TileDef, SpecFacet, FacetType and FacetScale are exported too.
ESM with sideEffects: false, so only the charts you import end up in your bundle.
Related packages
- ztd-charts-cli: validate specs and render them to PNG, SVG or HTML from the terminal.
- ztd-charts-mcp: an MCP server so an AI agent can pick, check and render charts.
License
MIT. Renamed from @junhanlee/chart-kit in 0.2.0: CSS names moved from --ck-*, .ck-* and data-ck-theme to --ztd-*, .ztd-* and data-ztd-theme.
