Sparkline
Examples
Section titled “Examples”Trend: Flat: With fill:
import { Sparkline } from '@eekodigital/raster';
<Sparkline width={80} data={[10, 25, 18, 40, 35, 60, 72, 86]} color="var(--demo-good)" title="Upward trend" />
<Sparkline width={80} data={[5, 15, 10, 30, 25, 45]} fill color="var(--demo-accent)" title="Growth" />Accessibility
Section titled “Accessibility”- The drawing is
aria-hidden. A visually hidden text summary carries the information instead of a data table:{title}: Sparkline, 8 points. Values from 10 to 86. First 10, last 86. - It has no marks to focus, so it adds no tab stops.
- Reword or translate the summary with
labels.summary.
See the Accessibility guide for the shared structure, the labels prop and screen-reader testing.
| Prop | Type | Description |
|---|---|---|
data | number[] | Required. Two or more values. |
title | string | Required. What the values are. Not displayed; it leads the text summary. |
width | number | Fixed width in px. Omit to fill the container’s width. |
height | numberDefault: | Height in px. |
color | stringDefault: | Line colour. |
fill | booleanDefault: | Fill below the line. |
formatValue | (value: number) => stringDefault: | Formats values in the summary. |
labels | ChartLabelOverridesDefault: English | Summary wording and number locale. |
ref | Ref<HTMLSpanElement> | The chart’s root element, e.g. for |
className | string |