Calm motion: animations on this site only fade, with no movement
Box plot
The spread of values in groups
Shows where most values of a group are, and which values are far from the rest, for example how long people listen on each day. An average hides this spread. For two numbers on each item, use the scatter chart.
Basic
| Group | Low | Lower quartile | Median | Upper quartile | High | Outliers |
|---|---|---|---|---|---|---|
| Mon | 12 | 17 | 18 | 21 | 27 | – |
| Tue | 15 | 20 | 21 | 24 | 29 | 52 |
| Wed | 8 | 14 | 16 | 19.3 | 26 | – |
| Thu | 19 | 23 | 24 | 26 | 30 | 31, 31, 58, 61 |
| Fri | 20 | 26 | 28 | 32 | 39 | – |
groupsis a list of{ label, values, color }. You give the raw values, and the chart computes the rest. A value that is not a number is left out.- The box goes from the lower quartile to the upper quartile, so it holds the middle half of the values. The line in the box is the median.
- The whiskers go to the lowest and the highest value that are inside 1.5 × the height of the box. A value outside that is an outlier and has its own dot.
- The quartiles use the linear method of most spreadsheets. A group with no values gets its label and no box.
- A hover on a box shows its numbers. The chart draws at the width of its container, and
heightsets the height (default 280). - The chart is hidden from screen readers, and a table of the numbers of each group is read in its place.
labelnames the table.formatsets the text of a value. Change the column names withlabelsor a label pack:group,min,q1,median,q3,max, andoutliers. - The chart is drawn as plain SVG. There is no chart library to install.
Usage
ts
import { BlessBoxPlot, type BlessBoxGroup } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
groups* | BlessBoxGroup[] | — | |
height | number | 280 | |
format | ((v: number) => string) | — | text for one value, for example `(v) => v + " ms"` |
label | string | "Chart" | names the chart and its table for screen readers |
labels | Partial<{ group: string; min: string; q1: string; median: string; q3: string; max: string; outliers: string; }> | — |