Examples

Response times

Preview
Response time by region (ms)Box plot of 3 groups. EU: median 160, quartiles 140 to 170, range 120 to 190, 1 outliers; US: median 117.5, quartiles 106.25 to 131, range 90 to 150; APAC: median 240, quartiles 210 to 300, range 180 to 330.
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Example.tsx
import { BoxPlot } from '@reactloom/charts';

const data = [
  { region: 'EU', ms: [120, 135, 140, 150, 160, 165, 170, 190, 420] },
  { region: 'US', ms: [90, 95, 110, 115, 120, 128, 140, 150] },
  { region: 'APAC', ms: [180, 200, 210, 230, 240, 260, 300, 310, 330] },
];

export default function Example() {
  return <BoxPlot title="Response time by region (ms)" data={data} label="region" values="ms" />;
}

Exam scores

Preview
Exam scoresClass B has a wider spread and two high scores.
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Exam scores (data)
CategoryMinQ1MedianQ3MaxOutliers
Class A526570.57888
Class B456370.575.59098
Example.tsx
import { BoxPlot } from '@reactloom/charts';

const classes = [
  { name: 'Class A', scores: [52, 61, 64, 68, 70, 71, 75, 79, 83, 88] },
  { name: 'Class B', scores: [45, 58, 62, 66, 69, 72, 74, 76, 90, 98] },
];

export default function Example() {
  return <BoxPlot title="Exam scores" description="Class B has a wider spread and two high scores." data={classes} label="name" values="scores" table="visible" />;
}

API reference

BoxPlot props
PropTypeDefault
datarequired
Row[]—
labelrequired
Group name.
key or accessor—
valuesrequired
The group’s raw values.
key or (row) => number[]—
titlerequired
Names the figure.
string—
description
The takeaway; a factual summary is generated when omitted.
ReactNode—
table
The data table alternative.
'toggle' | 'visible' | 'none''toggle'
height · valueFormat · formatValue · messages
As on the other charts.
—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-active]present when on

Theme tokens it reads

--pl-color-border-default --pl-color-fg-default --pl-color-fg-muted

Accessibility

  • The chart is a figure named by its title and described by a summary; the drawing is hidden from assistive technology.
  • The plot is one tab stop: arrow keys move between items and each is announced; the data table gives every value.
  • Each group is read as median, quartiles, range and the number of outliers.
Keyboard interactions
KeyAction
TabFocus the plot
← → ↑ ↓Move between items
Home / EndFirst / last item
EscapeClear the highlight

Usage guidelines

Do

  • Explain box plots once on the page for general audiences.

Don’t

  • Don't use for fewer than about five values per group — show the points.