# Chart

A plot's frame: its rows, scale and height, with a dashed grid, both axes, a legend and a reading by pointer, touch and keys.

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

```tsx
import {
  Chart, Grid, XAxis, YAxis, Legend, Readout, chartColor, fmtTick,
} from "@arcadia/ui/charts";
```

A month of requests per second. Point at the plot, tap it or use the arrow keys to read a day.

```tsx
import {
  Chart, Grid, YAxis, XAxis, Area, chartColor, Readout,
} from "@arcadia/ui/charts";

<Chart label="Requests per second" x={DAYS} size="lg">
  <Grid />
  <YAxis />
  <XAxis />
  <Area label="Requests" values={RATE} color={chartColor(1)} />
  <Readout />
</Chart>
```

## Accessibility

A chart is named from its data: what it counts, how many rows, each series' first and last value and the change, and a stack's total. The first specimen is "Requests per second: 30 days, from 206 to 750, up 264%". Without `Readout` the plot is one image (`role="img"`) with that name, and not a Tab stop.

With `Readout` the plot is one Tab stop, a horizontal slider (`role="slider"`): its name the same, its range the rows from 1 to their count, its value the read row, and its value text that row's reading, the row and then each series with its value. On the first specimen's newest row that is "Tue, Oct 6: Requests 750". The value text is the announcement, so the chart has no status region. The focus ring is the kit's, 12px off the plot so it clears the dots' halos, and on a narrow plot it goes around the top value's row as well.

Under forced colours the marks, the reading's dots and the swatches keep their series' colours, which say which series is which; the grid, the labels and the crosshair take the system's ink.

The legend is a group of toggle buttons (`aria-pressed`), one Tab stop with the arrow keys inside, each at least 24px tall. The axes, the marks and the card are hidden from assistive technology, since the name and the value text say what they show. Colour is never the only key: the legend and the card name every series.

## API reference

### Chart

- `label` (`string`, required): What the chart 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.
- `size` (`"sm" | "md" | "lg"`, default `"md"`): `sm` 128px, `md` 192px, `lg` 256px, usually with 3, 4 and 5 rules.
- `unit` (`string`): A symbol every number carries (`ms`, `%`).
- `noun` (`readonly [one: string, many: string]`): What the name calls a row, `["service", "services"]`; dates name themselves.
- `partialLast` (`boolean | ChartPartialLast`)
- `buckets` (`boolean`): Each row is a period (a day, a week) with its own equal slot: a `step` mark holds its value across the slot, and the reading, its rule and the date labels sit in the slot's middle. For counts per period.
- `keepOneSeries` (`boolean`): Keep the last visible series on when filtering in the legend.
- `highlight` (`Key | null`, default `null`): The React key of the mark to light, as when pointing at a legend item.
- `sum` (`boolean`, default `true`): Read a stack's sum as its Total, under its parts. off where a mark of the chart's own is the total.
- `readoutDescription` (`string`): ID of optional instructions for the interactive plot.
- `rootStyle` (`RootStyle<ChartKnobs>`)

Rest props go to `HTMLAttributes<HTMLDivElement>`.
