# Sparkline

The shape of a trend beside its number, as a line, an area or bars, read by that number.

Live variants: https://design.arcadia.is/components/sparkline

```tsx
import { Sparkline } from "@arcadia/ui/charts";
```

Each sparkline beside its number: a line for a measure, an area for an amount, bars for a count of its own each day.

- `line`: response time
- `area`: requests
- `bars`: deploys

## Accessibility

A sparkline is named from its data, as a plot is: what it counts, how many rows, its first and last value and the change. The area above is "Requests per day: 29 days, from 8.1K to 9.1K, up 12%". Without a reading it is one image (`role="img"`) with that name, and not a Tab stop, so a table of them is read as their names.

With `onRead` it is one Tab stop, a horizontal slider (`role="slider"`) over its rows: its name the same, its value the read row, and its value text that row's reading, "Tue, Oct 6: 9,100". The value text is the announcement, so the number beside it needs no status region of its own.

The focus ring is the kit's, 6px off the sparkline so it clears the read dot. A 16px sparkline that reads takes the pointer 4px above and below it, so its target is 24px tall without growing the row.

## API reference

### Sparkline

- `label` (`string`, required): What it counts ("Requests per day"): its name starts with it.
- `x` (`readonly (string | number | Date)[]`, required): The rows, oldest first: days as `yyyy-mm-dd`, timestamps, or names.
- `values` (`readonly (number | null | undefined)[]`, required): A value per row; `null` is a gap.
- `kind` (`"line" | "area" | "bars"`, default `"line"`)
- `size` (`"sm" | "md" | "lg"`): 16, 24 or 32px; `lg` in a `Stat`.
- `color` (`string`, default `chartColor(1)`): The paint of the slot its entity owns.
- `curve` (`"monotone" | "straight" | "step"`, default `"monotone"`)
- `unit` (`string`): A symbol every number carries (`ms`, `%`).
- `format` (`(value: number) => string`): How a read value is written: `fmtCount`, `fmtPercent`.
- `onRead` (`(point: SparkPoint | null) => void`): Turns the reading on: called with each point read, then `null` when the reading ends.
- `rootStyle` (`RootStyle<SparklineKnobs>`)

Rest props go to `HTMLAttributes<HTMLDivElement>`.
