Description:
ztd charts is a React chart library for dashboards and reports.
The chart cards put a written takeaway alongside the plot, and a JSON spec can drive both the chart in your app and a PNG export.
Preview

Features
- Trend, flow, cohort, map, and KPI charts for different reporting tasks.
- Drag-to-select ranges on line, area, and candlestick charts.
- Keyboard navigation and data tables for assistive technology.
- Light and dark themes with per-chart accent colors.
- English and Korean number formats and chart text.
Add a chart card
Install the package in your React project.
npm install ztd-chartsUse label and value to map the fields in your data. Set highlight to the category you call out in the card’s takeaway.
import { ChartCard, PieChart } from "ztd-charts";
const signups = [
{ channel: "Organic", count: 480 },
{ channel: "Referral", count: 250 },
{ channel: "Paid", count: 170 },
];
export function SignupMix() {
return (
<ChartCard
title="Signups by channel"
takeaway="Organic search drove over half of signups."
>
<PieChart
data={signups}
label="channel"
value="count"
highlight="Organic"
/>
</ChartCard>
);
}ChartCard and PieChart props
| Prop | Effect |
|---|---|
ChartCard.title, subtitle, takeaway | Give the card its heading, add context or units, and put a conclusion below the plot. |
ChartCard.legend, actions | Pass a legend array or React node. Use actions for controls that belong beside the title. |
ChartCard.replay, onReplay | Add a button to replay the chart animation and receive a callback when the button is pressed. |
PieChart.data, label, value | Pass the rows and map the label and numeric fields. The field accessors accept a key or a function. Their default keys are "label" and "value". |
PieChart.highlight, colorMode | Pick the category to accent. The default "categorical" mode varies the gray tones. Set "emphasis" to color only the highlight. |
PieChart.labelMode, sort, other | Choose percentage, value, label, or no slice labels with "percent", "value", "label", or "none". Sorting is off by default. Pass a number to other to keep that many largest slices and group the rest. |
width, height, tooltip | Set plot dimensions in pixels. With no width, the plot fits its parent. Pass false to disable the tooltip or a function to customize its contents. |
onClick(event), onHover(event) | Use event.datum to get the source row. The layout index can differ from the input index after sorting. onHover receives null when hover or focus clears. |
Configure the dashboard theme and range selection
Set theme="light" or theme="dark" on ThemeProvider. Set paint when the provider should also apply the dashboard background and text colors. Pass a chart-level theme override to change an individual chart’s accent.
Use a funnel for stage drop-off, a cohort chart for retention, or a KPI table to compare metrics.
On line, area, and candlestick charts, set brush="zoom" to zoom into a selected range. Read from, to, fromLabel, and toLabel from onBrush to apply the range to another chart or filter.
Render a chart from JSON
If you store report definitions as data, save the example below as signups.json. type selects the plot, encoding maps its data fields, and options sets its highlight.
{
"type": "pie",
"data": [
{ "channel": "Organic", "count": 480 },
{ "channel": "Referral", "count": 250 },
{ "channel": "Paid", "count": 170 }
],
"encoding": { "label": "channel", "value": "count" },
"options": { "highlight": "Organic" }
}In a React app with JSON imports, pass the saved object to Chart:
import { Chart } from "ztd-charts";
import signupSpec from "./signups.json";
export function SignupChartFromSpec() {
return <Chart spec={signupSpec} />;
}From the directory containing signups.json, run the CLI on Node.js to export the plot to PNG.
npx --package=ztd-charts-cli ztd-charts render signups.json --out signups.png --theme lightRendering large datasets
Scatter plots switch to Canvas at 1,500 points and heatmaps at 2,500 cells. Axes and labels stay in SVG.