Chart

Area, line, bar and sparkline charts drawn in plain SVG. Curves draw in, bars grow, data changes morph, and the tooltip follows your cursor.

Data Display
Visitors
113,325

Playground

Tweak the props, the preview and the code follow.

Props
<AreaChart
  data={data}
  index="month"
  series={[
    { key: "signups", label: "Signups" },
    { key: "trials", label: "Trials" },
  ]}
/>

Installation

npx @plumsydev/plum-ui add chart

Usage

import { AreaChart, BarChart, LineChart, Sparkline } from "@/components/ui/chart"
<AreaChart
  data={data}
  index="month"
  series={[
    { key: "desktop", label: "Desktop" },
    { key: "mobile", label: "Mobile" },
  ]}
/>

Examples

Bar chart

Grouped or stacked. The legend toggles series.

Revenue by source
Click the legend to hide a series

Live data

Feed new points and the line glides instead of jumping.

Response time
api.acme.com · last 30 seconds
Live

Sparklines

Tiny trend lines for KPI cards.

Click a card to refresh the data.

API Reference

AreaChart / LineChart / BarChart

PropTypeDefault
data*

One object per x value.

Record<string, string | number>[]—
index*

Key used for the x axis.

string—
series*

Values to plot. Colors default to the theme palette.

{ key: string; label?: string; color?: string }[]—
height

Height in px. Width follows the container.

number260
stacked

Stack series on top of each other.

booleanfalse
grid / xAxis / yAxis / legend / tooltip

Toggle chart furniture.

booleantrue
valueFormatter

Formats ticks and tooltip values.

(value: number) => string—
curve

Area and line only.

"smooth" | "linear""smooth"
dots

Area and line only. Show a dot on each point.

booleanfalse

Sparkline

PropTypeDefault
data*

The values.

number[]—
color

Stroke color.

string"var(--brand)"
fill

Gradient under the line.

booleantrue

Notes

  • Define --chart-1 to --chart-5 in your theme to change the default palette.
  • Smooth curves use monotone interpolation, so they never overshoot your data.