Charts · line, bar, pie & more
Fourteen SVG charts that size to their box and follow the theme: line, area, column, bar, pie, donut, scatter, bubble, radar, heatmap, gauge, funnel, treemap, radial bar and waterfall. Data can be a signal — change it and the chart animates from the old numbers to the new ones, axes included. Colours come from the theme's --zap-chart-1…8 tokens in a fixed order, so a series keeps its colour when others are hidden.
Hover for values · click a legend entry to hide a series
Usage
import { signal } from "./index.js";import { LineChart, AreaChart, ColumnChart, BarChartH, PieChart, DonutChart, ScatterChart, RadarChart, Heatmap, Gauge, Funnel, Treemap, RadialBar, WaterfallChart } from "./components/chart.js"; // Data may be plain, a signal or a getter — set it and the chart tweens to the new numbers.const series = signal([{ name: "Online", data: [62, 70, 75] }, { name: "Retail", data: [48, 44, 51] }]);LineChart({ labels: ["Jan", "Feb", "Mar"], series, format: (v) => "$" + v + "K" })AreaChart({ labels, series, stacked: true })ColumnChart({ labels: ["Q1", "Q2", "Q3", "Q4"], series, stacked: false }) // horizontal: true → barsDonutChart({ data: [{ label: "Kartex", value: 42 }, { label: "Others", value: 58 }], centerLabel: "points" })ScatterChart({ series: [{ name: "Won", data: [{ x: 12, y: 80, r: 40 }] }] }) // r → bubblesRadarChart({ axes: ["Speed", "Cost", "Recall"], series, max: 100 })Heatmap({ x: hours, y: days, values: grid, showValues: true })Gauge({ value: cpu, label: "CPU", format: (v) => v + "%" })Funnel({ data: [{ label: "Visited", value: 12000 }, { label: "Signed up", value: 4100 }] })Treemap({ data: spend }) // > 8 entries fold into "Other"RadialBar({ data: [{ label: "Move", value: 72 }] })WaterfallChart({ data: [{ label: "Revenue", value: 420 }, { label: "COGS", value: -150 }, { label: "Net", total: true }] })