On this page

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 #

Terminal
npm i tally-charts
app/deliveries.tsx
import { 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.

Days to deliver, promised against actual
View of Days to deliver, promised against actual
Days to deliver, promised against actual
OrderPromisedActual
#210158
#210223
#210334
#210457
#210524
#210624
#210734
#210821
#210943
#211056
#211122
#211223
#211355
#211444
#211523
#211623
#211746
#211822
#211957
#212043
#212157
#212222
#212335
#212445

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.

Practice exam scores, three attempts per student
View of Practice exam scores, three attempts per student

Dots in a row that would overlap are lifted, so each one stays visible.

Props #

NameTypeDefaultRequiredDescription
activeIdId | null—No—
animateboolean—No—
aria-labelledbystring—No

Id of an element that names the chart; it wins over title for the name.

axisTickSpec | 'none'5No

Value axis ticks, or 'none'. Default 5.

axisFormatAxisFormat`format`No

Axis label format. Default: format.

chartIdstring—No

Prefix for pattern and mask ids. React's useId is only unique within one root, so set this when charts render in several React roots on one page.

childrenReactNode—No—
classNamestring—No—
datareadonly D[]—Yes—
dataTableboolean | DataTableOptionstrueNo

Hidden data table for screen readers: true, false, or { caption, columns } to set its caption and rename column headers. Default true.

descriptionstring—No

Accessible description, usually the takeaway sentence.

dimInactiveboolean—No—
domainreadonly [number, number]the range of all values without forcing zero, rounded to nice ticksNo

Value domain. Default: the range of all values without forcing zero, rounded to nice ticks.

emptyReactNode"No data"No

Rendered instead of the plot when data is an empty array. Default "No data".

formatFormatSpec'number'No

Default 'number'.

heightnumber240 unless `aspectRatio` is setNo

Height in px. Default 240 unless aspectRatio is set.

idAccessor<D, Id>the data indexNo

Item id. Default: the data index.

initialWidthnumber640No

Width used for server rendering and the first client render. Default 640.

keyboardHintstring"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 onSelect. A custom text is used as is. Set it to translate the text; "" turns it off.

labelAccessor<D, string>—No

Item name for announcements and tooltips.

labelWidthnumber96No

Label column width in px. Default 96.

marginPartial<Margin>—No—
medianbooleantrueNo

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; point.datum is the row from data.

onSelect(id: Id, point: ChartPoint<D>) => void—No

Called on click, Enter or Space; point.datum is the row from data.

radiusnumber4No

Dot radius in px. Default 4.

rowHeightnumber72No

Default 72.

seriesreadonly StripSeries<D>[]—Yes

One row of dots per series.

styleCSSProperties—No—
titlestring—No

Accessible name of the chart; also the default caption of the data table.

tooltipChartTooltip<D>trueNo

Tooltip on hover and focus: true for the default pill, or a function that renders the content for a point (point.datum is your row). Default true.

widthnumber—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.