Charts
StripPlot
The same items measured more than once, one row of dots for each measure. Every item appears as one dot in every row, so the rows show how the measures differ in spread and position, and a dashed median marks the middle of each.
When to use it #
Use StripPlot to compare several measures of the same items: an estimate against the actual, a promise against a delivery, a score on each attempt. Each entry of series is a row with a label, a value accessor and an optional tone; median draws a dashed line and a label per row (on by default). The axis does not force zero, so the rows fill the width, and domain fixes it when you want to.
If you have a single measure and want to see how the items bunch up, use DotHistogram: the dots stack in bins instead of lining up in rows. If you want totals per period, use WaffleColumns: a column of dots for each period.
Import #
npm i tally-chartsimport { StripPlot } from 'tally-charts'
import 'tally-charts/theme.css'Examples #
Two rows, Promised and Actual. value is a field name, so the series stay serializable, and the medians show the gap between the two.
| Order | Promised | Actual |
|---|---|---|
| #2101 | 5 | 8 |
| #2102 | 2 | 3 |
| #2103 | 3 | 4 |
| #2104 | 5 | 7 |
| #2105 | 2 | 4 |
| #2106 | 2 | 4 |
| #2107 | 3 | 4 |
| #2108 | 2 | 1 |
| #2109 | 4 | 3 |
| #2110 | 5 | 6 |
| #2111 | 2 | 2 |
| #2112 | 2 | 3 |
| #2113 | 5 | 5 |
| #2114 | 4 | 4 |
| #2115 | 2 | 3 |
| #2116 | 2 | 3 |
| #2117 | 4 | 6 |
| #2118 | 2 | 2 |
| #2119 | 5 | 7 |
| #2120 | 4 | 3 |
| #2121 | 5 | 7 |
| #2122 | 2 | 2 |
| #2123 | 3 | 5 |
| #2124 | 4 | 5 |
import { StripPlot } from 'tally-charts'
import type { ExampleMeta } from '../types'
export const meta = {
id: 'strip-plot/delivery-days',
title: 'Days to deliver, promised against actual',
rscSafe: true,
} satisfies ExampleMeta
const promised = [5, 2, 3, 5, 2, 2, 3, 2, 4, 5, 2, 2, 5, 4, 2, 2, 4, 2, 5, 4, 5, 2, 3, 4]
const actual = [8, 3, 4, 7, 4, 4, 4, 1, 3, 6, 2, 3, 5, 4, 3, 3, 6, 2, 7, 3, 7, 2, 5, 5]
const orders = promised.map((p, i) => ({ order: `#${2101 + i}`, promised: p, actual: actual[i] }))
// Props stay serializable (`value` is a field name, not a function): the page is a server component.
export default function DeliveryDays() {
return (
<StripPlot
title={meta.title}
description="Across 24 orders, the median promise is 3 days and the median delivery 4. 16 orders arrived later than promised."
data={orders}
label="order"
series={[
{ id: 'promised', label: 'Promised', value: 'promised' },
{ id: 'actual', label: 'Actual', value: 'actual', tone: 'warn' },
]}
domain={[0, 9]}
axis={9}
/>
)
}
Three rows with their own tones. median={false} removes the dashed lines, domain sets the axis, and radius, rowHeight and labelWidth size the dots, the rows and the label column.
import { StripPlot } from 'tally-charts'
import type { ExampleMeta } from '../types'
export const meta = {
id: 'strip-plot/exam-attempts',
title: 'Practice exam scores, three attempts per student',
rscSafe: true,
} satisfies ExampleMeta
const scores = [
[58, 67, 79],
[63, 74, 76],
[68, 75, 78],
[56, 63, 70],
[62, 66, 72],
[63, 65, 73],
[72, 79, 86],
[54, 65, 69],
[51, 59, 64],
[54, 61, 72],
[60, 62, 72],
[73, 83, 86],
[56, 59, 63],
[76, 86, 93],
[61, 68, 73],
[70, 70, 79],
[71, 71, 80],
[63, 72, 72],
]
const students = scores.map(([first, second, third], i) => ({
student: `Student ${i + 1}`,
first,
second,
third,
}))
// Props stay serializable: no median line, a fixed domain and a smaller row.
export default function ExamAttempts() {
return (
<StripPlot
title={meta.title}
description="Scores rise with each attempt: the first ranges from 51 to 76, the third from 63 to 93. No student scored lower on a later attempt."
data={students}
label="student"
series={[
{ id: 'first', label: 'Attempt 1', value: 'first', tone: 'neutral' },
{ id: 'second', label: 'Attempt 2', value: 'second', tone: 'accent-soft' },
{ id: 'third', label: 'Attempt 3', value: 'third', tone: 'accent' },
]}
median={false}
domain={[40, 100]}
radius={5}
rowHeight={64}
labelWidth={88}
/>
)
}
Dots in a row that would overlap are lifted, so each one stays visible.
Props #
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
activeId | Id | null | — | No | — |
animate | boolean | — | No | — |
aria-labelledby | string | — | No | Id of an element that names the chart; it wins over |
axis | TickSpec | 'none' | 5 | No | Value axis ticks, or 'none'. Default 5. |
axisFormat | AxisFormat | `format` | No | Axis label format. Default: |
chartId | string | — | No | Prefix for pattern and mask ids. React's |
children | ReactNode | — | No | — |
className | string | — | No | — |
data | readonly D[] | — | Yes | — |
dataTable | boolean | DataTableOptions | true | No | Hidden data table for screen readers: |
description | string | — | No | Accessible description, usually the takeaway sentence. |
dimInactive | boolean | — | No | — |
domain | readonly [number, number] | the range of all values without forcing zero, rounded to nice ticks | No | Value domain. Default: the range of all values without forcing zero, rounded to nice ticks. |
empty | ReactNode | "No data" | No | Rendered instead of the plot when |
format | FormatSpec | 'number' | No | Default 'number'. |
height | number | 240 unless `aspectRatio` is set | No | Height in px. Default 240 unless |
id | Accessor<D, Id> | the data index | No | Item id. Default: the data index. |
initialWidth | number | 640 | No | Width used for server rendering and the first client render. Default 640. |
keyboardHint | string | "Use arrow keys to move between points, Home and End for first and last, Escape to clear.", plus " Press Enter to select." while the active point (or the first, before one is active) can be selected with `onSelect` | No | Instructions read with the chart when it takes keyboard focus. Default: "Use arrow keys to move between points, Home and End for first and last, Escape to clear.", plus " Press Enter to select." while the active point (or the first, before one is active) can be selected with |
label | Accessor<D, string> | — | No | Item name for announcements and tooltips. |
labelWidth | number | 96 | No | Label column width in px. Default 96. |
margin | Partial<Margin> | — | No | — |
median | boolean | true | No | Dashed median line and label per row. Default true. |
onActiveChange | (id: Id | null, point: ChartPoint<D> | null) => void | — | No | Called with the new active id, and its point; |
onSelect | (id: Id, point: ChartPoint<D>) => void | — | No | Called on click, Enter or Space; |
radius | number | 4 | No | Dot radius in px. Default 4. |
rowHeight | number | 72 | No | Default 72. |
series | readonly StripSeries<D>[] | — | Yes | One row of dots per series. |
style | CSSProperties | — | No | — |
title | string | — | No | Accessible name of the chart; also the default caption of the data table. |
tooltip | ChartTooltip<D> | true | No | Tooltip on hover and focus: |
width | number | — | No | Fixed width in px; turns off container measuring. |
Keyboard and screen readers #
StripPlot is built on Chart, so it follows the same keyboard model as the other charts: it is a single tab stop, and tabbing in shows the first dot with its tooltip and announces it. Its dots form rows, so it moves in two dimensions: ← and → walk along a row, ↑ and ↓ change to the previous or next row. Home and End jump to the first and last point, Enter or Space selects the active point when the chart has onSelect, and Esc clears the active point. Esc is only consumed when a point is active, so an enclosing dialog still closes. The widget’s description ends with a keyboard hint (“Use arrow keys to move between points, Home and End for first and last, Escape to clear.”, plus “Press Enter to select.” with onSelect); keyboardHint replaces it, for example to translate it, and keyboardHint="" turns it off.
Screen readers get the chart title and description, then an announcement for each dot the keyboard moves to, in the form “Estimated, 1 of 29, #5900, 5.2 h”: the row’s label as the series, the position within that row, the item’s label and its value. A visually hidden data table follows the chart with an Item column (named after the label field when it is a string) and one column for each series, so the table has the measures of an item on one line. dataTable renames the caption and headers, or turns it off.
The SVG and the HTML overlay are aria-hidden, so the median lines and their labels say nothing to a screen reader. Put the medians in the title or the description, as both examples do.
The full model is in the accessibility guide.