ScatterChart
Scatter chart, 5 points. 8 to 45. Values from 1 to 12.
Show data table
| Label | Page complexity | Issues found |
|---|---|---|
| Homepage | 12 | 3 |
| Dashboard | 28 | 7 |
| Settings | 45 | 12 |
| About | 8 | 1 |
| Reports | 35 | 9 |
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"
/>Multi-series
Section titled “Multi-series”Scatter chart, 2 series, 6 points. 10 to 50. Values from 2 to 10.
Show data table
| Series | Elements | Violations |
|---|---|---|
| Audit 1 | 10 | 2 |
| Audit 1 | 25 | 5 |
| Audit 1 | 40 | 8 |
| Audit 2 | 15 | 4 |
| Audit 2 | 30 | 3 |
| Audit 2 | 50 | 10 |
<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"
/>Dates on x
Section titled “Dates on x”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"/>;Reference lines
Section titled “Reference lines”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"/>Accessibility
Section titled “Accessibility”- A
role="figure"named by the visibletitleand described by a generated summary (chart type, series and point counts, range). - The SVG is a
role="group"witharia-roledescription="chart"; nographics-*roles. - Named series are
role="group"s. Each point is labelled{series}, {x}: {y}, 3 of 12(with itslabelwhen given). WithonSelect,selectedIndexor a click handler, marks arerole="button"witharia-pressed; otherwise they’re staticrole="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 captionedData for {title}, withth scopeheaders and values run throughformatXandformatValue. - 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.
| Prop | Type | Description |
|---|---|---|
data | ScatterPoint[] | Single series: |
series | ScatterSeries[] | Named series: |
xLabel | string | X-axis title. |
yLabel | string | Y-axis title. |
grid | “horizontal” | “vertical” | “both” | “none”Default: | Grid lines. |
formatValue | (value: number) => stringDefault: | Formats y values, and x values unless |
xAxis | XAxis | A date axis: |
formatX | (value: number) => stringDefault: | Formats x values separately, e.g. epoch milliseconds as dates:
|
referenceLines | { value: number, label: string, axis?: “x” | “y” }[] | Targets and thresholds as dashed, labelled lines, across y or (with |
height | numberDefault: | Plot height in px. |
aspectRatio | number | Width ÷ height, instead of |
onMarkClick | | Called when a mark is clicked (or activated with Enter/Space) with
|
selectedIndex | { series, point } | null | Controlled selection. |
onSelect | (index | null) => void | Makes points buttons. |
title | string | Required. Visible title: names the figure and captions the data table. |
hideTitle | booleanDefault: | Hide the title visually. It still names the chart for assistive technology. |
labels | ChartLabelOverridesDefault: English | Generated strings and the number locale. See Accessibility. |
dataTable | “disclosure” | “visually-hidden” | “none”Default: | 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. |
actions | ReactNode | Shown on the same row as the Show data table button, such as download buttons. |
ref | Ref<HTMLDivElement> | The chart’s root element, e.g. for |
className | string | Class on the figure. |