Skip to content
Thrum

Live chart

A line for a value that keeps arriving: latency, throughput, queue length. Your code owns the samples and adds one every second or so; the chart slides to each new one and marks the newest point. For a fixed set of points with a reading cursor, use the area chart or the line chart.

Install

npx shadcn@latest add @thrum-pro/live-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 LiveChartPoint = {
  time: number;         // milliseconds, for example Date.now()
  value: number | null; // null = missed sample, leaves a gap
};
Sample
[
  { time: 1796212800000, value: 212 },
  { time: 1796212801000, value: 230 },
  { time: 1796212802000, value: null },
  { time: 1796212803000, value: 224 },
]

Props

PropTypeDefaultDescription
datareadonly LiveChartPoint[]RequiredSamples in order, oldest first. The parent owns the list and adds each new sample at the end. Samples older than the window can stay in the list; they are not drawn.
labelstringRequiredWhat the chart measures. Shown beside the latest value, read by screen readers and used as the table caption.
windownumberDefault 60000How much time the plot shows, in milliseconds, counted back from the newest sample.
colorstringDefault var(--chart-1)Any CSS colour for the line and the marker.
formatIntl.NumberFormatOptionsDefault compactHow values are written on the axis, in the readout and in the data table.
localestringDefault "en-US"Locale for numbers and for the time labels.
yAxisbooleanDefault trueShow value lines and their labels. The axis fits the samples in the window and the limit, with round ends.
xAxisbooleanDefault trueShow the two ends of the time span along the bottom, for example “60s ago” and “now”.
thresholdnumber–Draws a dashed limit line with its value. A signal plays when the newest value climbs from at or below the limit to above it.
pausedbooleanDefault falseStops the slide and shows the word “Paused”. The chart steps to any sample that still arrives. To freeze the picture, also stop adding samples.
hideLabelbooleanDefault falseHide the label beside the latest reading when a surrounding panel already carries the heading.
soundbooleanDefault truePlay the limit signal and cursor scrub ticks, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when the window holds no value.
classNamestring–Sets the size. The default is full width and 256 pixels tall, readout included.

Motion and sound

Motion

  • A new sample: the line slides left by one step at constant speed. The slide lasts as long as the time between the last two samples, so with a steady feed the line never stops and never jumps.
  • The marker stays on the right edge and rides the line as the new segment comes in.
  • The value axis has round ends and changes only when a value leaves it or the range shrinks to a rounder one. The line then settles on the new scale in 400 ms with no overshoot.
  • Samples are joined with straight segments, so a part of the line that is already drawn never changes shape.
  • Nothing runs between samples: when no data arrives, nothing moves.
  • First draw: the line is revealed left to right in 700 ms, then the marker fades in.
  • Paused or reduced motion: no slide and no reveal. Each new sample redraws the chart once.

Sound

  • A two-tone signal when the newest value climbs over the limit. Nothing plays for the first reading, for a value that stays above the limit, or on the way down.
  • A soft tick as the pointer or keyboard cursor moves between samples in the window.

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

Accessibility

  • The plot is an image whose label states the latest value, the low and the high of the window, the limit and whether it is paused, for example “Latency: latest 212 ms, low 180 ms, high 347 ms, limit 300 ms”.
  • It is not a live region: a value that changes every second would flood a screen reader. Readers ask for the value when they want it.
  • A visually hidden table carries every sample in the window, with its age as the row header.
  • A chart that updates for more than five seconds needs a pause control. Give the reader a button that sets paused and stops your feed.
KeysAction
TabFocus the plot. The inspection cursor opens on the newest sample in the window.
← →Step backwards or forwards through samples in the window.
Home / EndJump to the oldest or newest sample in the window.
EscHide the sample readout.

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/live-chart.tsx
Packages
motion
Brings along
Chart foundationsMotion tokensSound engine

Changelog

  1. 1.0.0 · 2026-12-02First 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