Skip to content
  • System
  • Light
  • Dark
  • High contrast

ScatterChart

Complexity vs accessibility issues

Scatter chart, 5 points. 8 to 45. Values from 1 to 12.

0246810121401020304050Page complexityIssues found
Show data table
Data for Complexity vs accessibility issues
LabelPage complexityIssues found
Homepage123
Dashboard287
Settings4512
About81
Reports359
import { ScatterChart } from '@eekodigital/raster';

<ScatterChart
  data={[
    { x: 12, y: 3, label: 'Homepage' },
    { x: 28, y: 7, label: 'Dashboard' },
  ]}
  xLabel="Page complexity"
  yLabel="Issues found"
  title="Complexity vs issues"
/>
Audit comparison

Scatter chart, 2 series, 6 points. 10 to 50. Values from 2 to 10.

0246810120102030405060ElementsViolations
Audit 1Audit 2
Show data table
Data for Audit comparison
SeriesElementsViolations
Audit 1102
Audit 1255
Audit 1408
Audit 2154
Audit 2303
Audit 25010
<ScatterChart
  series={[
    { name: 'Audit 1', data: [...], color: 'var(--demo-accent)' },
    { name: 'Audit 2', data: [...], color: 'var(--demo-good)' },
  ]}
  xLabel="Elements"
  yLabel="Violations"
  title="Audit comparison"
/>

For dates, give x values as epoch milliseconds and pass a date axis from @eekodigital/raster/time. Ticks fall on days, weeks, months or years, and x values are worded as dates in point names, the summary and the table:

import { timeAxis } from "@eekodigital/raster/time";
<ScatterChart
data={orders} // { x: Date.parse(order.date), y: order.total }
xAxis={timeAxis(orders.map((p) => p.x))}
labels={{ locale: "en-GB" }}
title="Order value by date"
/>;

referenceLines draws dashed, labelled lines: across y by default, or vertical at an x value with axis: "x". Both scales stretch to include them. The x value is worded with formatX. They’re named in the summary and the table caption, and aren’t focusable.

<ScatterChart
data={points}
referenceLines={[
{ value: 4.5, label: "Pass mark" },
{ value: 60, label: "Time limit", axis: "x" },
]}
title="Score against time taken"
/>
  • A role="figure" named by the visible title and described by a generated summary (chart type, series and point counts, range).
  • The SVG is a role="group" with aria-roledescription="chart"; no graphics-* roles.
  • Named series are role="group"s. Each point is labelled {series}, {x}: {y}, 3 of 12 (with its label when given). With onSelect, selectedIndex or a click handler, marks are role="button" with aria-pressed; otherwise they’re static role="img".
  • Points use a different marker shape per series.
  • Arrow keys move in x order, so left and right match the drawing.
  • A visible Show data table disclosure (a native <details>/<summary>, so it opens without JavaScript) reveals a real table captioned Data for {title}, with th scope headers and values run through formatX and formatValue.
  • Escape (inside the chart only) clears the selection and announces it in a polite live region; it doesn’t close a surrounding dialog.
  • Animations stop under prefers-reduced-motion. In forced-colours mode marks use system colours, told apart by dash pattern and marker shape.
Key Action
← / → Previous / next mark
Home / End First / last mark
PageUp / PageDown Back / forward 10 marks
↑ / ↓ Previous / next series
Tab Leave the chart (one tab stop)
Enter / Space Toggle selection (interactive marks)
Escape Hide the tooltip and clear selection

See the Accessibility guide for the shared structure, the labels prop and screen-reader testing.

PropTypeDescription
dataScatterPoint[]

Single series: { x, y, label? }.

seriesScatterSeries[]

Named series: { name, data, color? }.

xLabelstringX-axis title.
yLabelstringY-axis title.
grid“horizontal” | “vertical” | “both” | “none”

Default: “both”

Grid lines.
formatValue(value: number) => string

Default: Intl.NumberFormat

Formats y values, and x values unless formatX is set, in ticks, marks, the table and the summary. Defaults to Intl.NumberFormat for labels.locale.

xAxisXAxis

A date axis: timeAxis(points.map((p) => p.x)) from @eekodigital/raster/time, with x as epoch ms. Calendar ticks, and x worded as dates. Overrides formatX.

formatX(value: number) => string

Default: formatValue

Formats x values separately, e.g. epoch milliseconds as dates: (ms) => dateFormat.format(ms). Ticks stay at evenly spaced numbers, thinned to fit the formatted labels.

referenceLines{ value: number, label: string, axis?: “x” | “y” }[]

Targets and thresholds as dashed, labelled lines, across y or (with axis: “x”) x. See Reference lines.

heightnumber

Default: 240

Plot height in px.
aspectRationumber

Width ÷ height, instead of height. The plot box is sized in CSS either way, so server-rendered and hydrated layouts match.

onMarkClick

(mark: { index: ScatterPointIndex, value, datum: ScatterPoint }) => void

Called when a mark is clicked (or activated with Enter/Space) with { index, value, datum }; index is what onSelect gives. Makes marks toggle buttons.

selectedIndex{ series, point } | nullControlled selection.
onSelect(index | null) => voidMakes points buttons.
titlestringRequired. Visible title: names the figure and captions the data table.
hideTitleboolean

Default: false

Hide the title visually. It still names the chart for assistive technology.
labelsChartLabelOverrides
Default: English

Generated strings and the number locale. See Accessibility.

dataTable“disclosure” | “visually-hidden” | “none”

Default: “disclosure”

How the data table is offered: behind a Show data table button, for screen readers only, or not at all, when you offer the data yourself. See Accessibility.

actionsReactNode

Shown on the same row as the Show data table button, such as download buttons.

refRef<HTMLDivElement>

The chart’s root element, e.g. for exportSVG and exportPNG from @eekodigital/raster/export. See Exporting charts.

classNamestringClass on the figure.