Skip to content
Thrum

Scatter chart

Points on two value axes, to show how two measures move together: deal size against days to close, price against rating. A third value can set each mark's area, and a trend line can summarise each series. For one measure over time, use the line chart.

Install

npx shadcn@latest add @thrum-pro/scatter-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 ScatterChartPoint = {
  x: number | null;     // null = not drawn, kept in the table
  y: number | null;
  size?: number | null; // drawn as the mark's area
  label?: string;       // shown in the readout
};
Sample
[
  { x: 12, y: 4200, size: 18, label: "Acme" },
  { x: 34, y: 18500, size: 42, label: "Northwind" },
  { x: 21, y: null, label: "Globex" },
]

Props

PropTypeDefaultDescription
seriesreadonly ScatterChartSeries[]RequiredUp to five series of { key, name, points, color? }. Each gets its own colour and its own shape: circle, square, triangle, diamond, then a triangle pointing down.
labelstringRequiredWhat the chart shows. Read by screen readers and used as the table caption.
xLabelstring–Name of the horizontal axis. Shown under it at the right, and in the readout. Without it the readout says “x”.
yLabelstring–Name of the vertical axis. Shown above it at the left, and in the readout. Without it the readout says “y”.
sizeLabelstringDefault "Size"Name of the size value in the readout and the table.
xFormatIntl.NumberFormatOptionsDefault compactHow horizontal values are written.
formatIntl.NumberFormatOptionsDefault compactHow vertical values are written.
sizeFormatIntl.NumberFormatOptionsDefault compactHow sizes are written.
localestringDefault "en-US"Locale for number formatting.
trendLinebooleanDefault falseDraw a dashed least-squares line through each series that has two or more points with different x values.
legendbooleanDefault trueShow the legend with each series' shape. It appears when there are two or more series.
onActiveChange(index: number | null) => void–Called with the index of the point under the cursor, counted left to right over all series, or null when the cursor leaves.
soundbooleanDefault truePlay a tick as the cursor moves between points, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when there is nothing to draw.
classNamestring–Sets the size. The default is full width and 256 pixels tall, legend included.

Motion and sound

Motion

  • First draw: the marks grow from their centres in 250 ms, left to right, and the whole entrance takes 550 ms at most.
  • New data with the same number of points: each mark and trend line moves to its new place in 400 ms with no overshoot. A different number of points is drawn again at once.
  • The cursor ring and the readout 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 point, 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, exposed as a slider whose value text is the point under the cursor, for example “Acme, Inbound: Days to close 12, Deal size $4.2K”.
  • A visually hidden table carries every point of every series, including points with a missing value that are not drawn.
  • Series differ in mark shape as well as colour, and the legend shows both. Marks are at least 8 px across, and size is drawn as area, so a value twice as large covers twice the ink.
  • Every mark has a 2 px ring of the background, so overlapping marks stay apart. The whole plot is the pointer target: the pointer reads the nearest point.
  • The readout is a floating surface. Under frosted glass it turns translucent and keeps its text at 4.5:1.
KeysAction
TabFocus the chart. The cursor goes to the right-most point.
← →Move to the next point to the left or right, over all series.
Home / EndJump to the left-most or right-most point.
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/scatter-chart.tsx
Packages
motion
Brings along
Chart foundationsMotion tokensSound engineChart tooltip

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