Content
- Name each series by what differs between them: Block 3, Block 7, Last year.
- Put the unit in
unit, so names stay short. - Keep x-axis labels short: 17 Sep, Mon, 6am.
- Name the series in a Legend above the plot.
A continuous series over time — the third renderer beside area and bar, and the one used for comparisons.
Hover the plot, or tab to it and use the arrow keys, to read each day.
<WLineChart
series={[
{ name: 'Block 3', data: block3 },
{ name: 'Block 7', data: block7 },
{ name: 'Block 12', data: block12 },
]}
labels={days}
height={260}
unit="%"
endLabels
ariaLabel="Soil moisture at blocks 3, 7 and 12, 17 to 29 September"
/>Y-axis labels, gridlines, a 2px line per series, x-axis labels, and each series’ latest value in the right gutter. Dots drop out where readings crowd closer than 12px.
Series take the chart ramp in order, and a reference series is grey.
const sites = [
{ name: 'Block 3', data: block3 },
{ name: 'Block 7', data: block7 },
{ name: 'Block 12', data: block12 },
];
<WLineChart series={sites} labels={days} height={200} unit="%" />
<WLineChart
series={[
{ name: 'This year', data: block3 },
{ name: 'Last year', data: lastYear, dashed: true },
]}
labels={days}
height={200}
unit="%"
/>
<WLineChart series={sites} labels={days} height={200} unit="%" smooth={false} showDots={false} />unit, so names stay short.Give every chart an ariaLabel that says what it compares and over what period. The plot is one tab stop, and a screen reader hears each reading as the arrow keys move.
| Key | What it does |
|---|---|
| Tab | Moves focus to the plot. |
| → / ↑ | Moves to the next reading, or the first. |
| ← / ↓ | Moves to the previous reading, or the last. |
| Home / End | Moves to the first or last reading. |
| Escape | Hides the readout. |
| Prop | Type | Default | Description |
|---|---|---|---|
| series | { name, data, times?, color?, dashed? }[] | — | Several series on one scale. null is no reading. |
| data | { label, value: number | null }[] | — | One series. Ignored when series is set. |
| labels | string[] | — | A label per reading, without times. |
| times / domain | number[] / [from, to] | — | Reading times and the window, in ms. |
| height | number | 300 | Total height in px, x-axis included. |
| minValue / maxValue | number | auto | The scale. Default: the readings, rounded to a tick. |
| unit / format | string / (v) => string | — | After each value, and how values round. |
| endLabels | boolean | false | Latest value per series in the gutter. |
| thresholds | Threshold[] | — | Dashed rules: value, label, short?, tone?. |
| band / bandLabel / bandTone | [lo, hi] / string / BandTone | — | A range band, named in the gutter. |
| answer | AnswerRowProps | — | Latest value, delta and verdict above the plot. |
| state | ChartState | 'ready' | ready, loading, refetching, empty, stale or partial. |
| showDots / showGrid / smooth | boolean | true | Dots, gridlines with y labels, and curved segments. |
| lineColor | string | SERIES_LONE | Colour of a single series. |
| ariaLabel | string | 'Line chart' | What the chart compares. The key hint is appended. |
| replay | number | 0 | Increment to replay the entrance. |
| Token | Value | Where it lands |
|---|---|---|
| SERIES_RAMP | #1877F2 | Series, in order; blue-1000 first. |
| SERIES_LONE | #00AEEF | A single series, blue-900. |
| SERIES_REFERENCE | #7F7D83 | Reference line, 1.5px, grey-900. |
| THRESH_LINE.warn | #EC980C | Warning threshold rule, squash-800. |
| T.ink3 | #4F4D55 | Axis labels, grey-1000. |
| T.grid | #F1F1F1 | Gridlines, grey-300. |
| T.baseline | #E6E6E6 | The baseline under the plot, grey-500. |
| RAMP.grey[1200] | #1D1C20 | Readout ground. |
| FOCUS | #1877F2 | Focus ring around the plot, blue-1000. |