Skip to content
Thrum

Combo chart

Amounts as bars with one or two lines over the same categories: orders against a target, sales against conversion. There is one value axis. A line on another scale is drawn indexed, as a percent of its own peak, so its shape can be compared with the bars while its real values stay in the readout. For several lines alone, use the line chart.

Install

npx shadcn@latest add @thrum-pro/combo-chart

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Data shape

Type
type ComboChartSeries = {
  key: string;
  name: string;
  values: (number | null)[]; // one per label
  color?: string;
};
type ComboChartLine = ComboChartSeries & {
  indexed?: boolean;
  format?: Intl.NumberFormatOptions;
};
Sample
bars: [{ key: "orders", name: "Orders", values: [1240, 1310, 1185] }],
lines: [{ key: "rate", name: "Conversion", indexed: true,
  values: [0.031, 0.034, 0.029], format: { style: "percent" } }]

Props

PropTypeDefaultDescription
labelsreadonly string[]RequiredNames of the categories on the horizontal axis, in order.
barsreadonly ComboChartSeries[]RequiredOne to three bar series, drawn side by side in each category, from zero. A fourth and later are left out.
linesreadonly ComboChartLine[]Default []Up to two lines through the middle of each category. A line drawn on the shared axis must measure the same thing as the bars. With indexed: true, the line is drawn as a percent of its own largest value, scaled so that peak sits level with the highest bar or line on the axis; the axis does not read its values, the readout and the table do.
labelstringRequiredWhat the chart measures. Read by screen readers and used as the table caption.
formatIntl.NumberFormatOptionsDefault compactHow values are written on the axis, in the readout and in the data table. A line's own format wins for that line.
localestringDefault "en-US"Locale for number formatting. Fixed by default so the server and the browser print the same text.
yAxisbooleanDefault trueShow value lines and their labels. The axis always includes zero.
xAxisbooleanDefault trueShow category labels along the bottom. Every nth one is shown so the widest has room.
legendbooleanDefault trueShow a swatch and a name for each series: a square for bars, a short line for lines, and “(indexed)” after an indexed line. It appears when there are two or more series.
onActiveChange(index: number | null) => void–Called with the index of the category under the cursor, or null when the cursor leaves.
soundbooleanDefault truePlay a tick as the cursor moves between categories, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when no series has a value.
classNamestring–Sets the size. The default is full width and 288 pixels tall, legend included.

Motion and sound

Motion

  • First draw: each group of bars grows from the zero line in 250 ms, 40 ms apart, while the lines are revealed left to right in 700 ms at constant speed.
  • New data with the same number of categories: bars and lines move to their new values in 400 ms with no overshoot. A different number switches at once.
  • The band behind the active category and the dots on the lines follow the pointer on a stiff spring.
  • Reduced motion: the chart appears complete, and data changes and the cursor move instantly.

Sound

  • A soft tick each time the cursor lands on a different category, at most one every 40 ms.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • The chart is one tab stop. It is exposed as a slider whose value text lists every series at the cursor, for example “Mar: Orders 1.2K, Target 1.3K, Conversion 2.9% (81% of its peak)”.
  • A visually hidden table carries every value of every series, lines in their own format.
  • Bars and lines are told apart by shape in the legend and the readout, not only by colour. Lines carry a ring of background where they cross a bar.
  • The whole plot is the pointer target, so a reader never has to hit a 2 pixel line.
KeysAction
TabFocus the chart. The cursor goes to the last category.
← →Move the cursor one category.
Home / EndJump to the first or last category.
EscHide the cursor.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/combo-chart.tsx
Packages
motion
Brings along
Chart foundationsMotion tokensSound engine

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor