Charts
BoxPlot
Compare distributions: median, quartiles, whiskers at 1.5 × IQR and outliers for each group.
import '@reactloom/charts/styles.css';
import { BoxPlot, boxStats } from '@reactloom/charts';Examples
Response times
Use the arrow keys to move between data points, Home and End to jump to the first and last.
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
Use the arrow keys to move between data points, Home and End to jump to the first and last.
| Category | Min | Q1 | Median | Q3 | Max | Outliers |
|---|---|---|---|---|---|---|
| Class A | 52 | 65 | 70.5 | 78 | 88 | |
| Class B | 45 | 63 | 70.5 | 75.5 | 90 | 98 |
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
| Prop | Type | Default |
|---|---|---|
datarequired | Row[] | — |
labelrequiredGroup name. | key or accessor | — |
valuesrequiredThe group’s raw values. | key or (row) => number[] | — |
titlerequiredNames the figure. | string | — |
descriptionThe takeaway; a factual summary is generated when omitted. | ReactNode | — |
tableThe data table alternative. | 'toggle' | 'visible' | 'none' | 'toggle' |
height · valueFormat · formatValue · messagesAs 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.
| Attribute | Values |
|---|---|
[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.
| Key | Action |
|---|---|
| Tab | Focus the plot |
| ← → ↑ ↓ | Move between items |
| Home / End | First / last item |
| Escape | Clear 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.