# Chart accessibility

Every chart ships with four things: a text alternative, a data table, colour-independent encoding, and keyboard-reachable detail.

## 1. Text alternative
- Static chart: `<img alt>` or inline SVG with `role="img"`, `<title>` and `<desc>` (samples in `samples/*.svg` do this).
- Alt text formula: **chart type, what it shows, range, the one insight.** "Bar chart of queries per day in thousands. Thursday is highest at 71; other days range from 38 to 63."
- Decorative charts (a duplicate of an adjacent table) get `alt=""`.

## 2. Data table fallback
Offer the same numbers as a real `<table>` in a `<details>` element under the chart (see `accessible-chart-pattern.html`). Tabular numerals, right-aligned, units in the header. Provide a CSV export link for anything over 50 cells.

## 3. Never colour alone
- Series: direct label + a second encoding (dash, marker shape, position). Series 5 and 6 are only allowed with both.
- Status: icon or word next to the colour (check, warning triangle, cross).
- Sequential and diverging scales: print the legend with Low/High (or the values) at the ends.

## 4. Contrast
- Text 4.5:1 (axis labels `--dr-text-secondary` on canvas = 5.1:1).
- Marks needed to read the chart: 3:1 against the background. Apple orange, teal and green are below 3:1 on white, so **any filled mark under 3:1 gets a 1 px outline** in a darker (light mode) or lighter (dark mode) shade of the same hue that reaches 3:1. Lines are at least 2.5 px and always directly labelled.
- Dark mode uses the dark ramps in `tokens/colors.css`; grid is `#38383A`.
- Forced-colors (Windows High Contrast): charts must not rely on fills. Add `@media (forced-colors: active) { .dr-chart * { forced-color-adjust: auto; } }` and keep outlines and labels.

## 5. Interaction
- Hover detail must also appear on keyboard focus (`tabindex="0"` on marks or a roving focus), and in the data table. No information is hover-only.
- Tooltips: appear on focus, dismiss with Esc, do not trap focus, stay while hovered (WCAG 1.4.13).
- Live-updating charts announce changes politely: `<div class="dr-sr-only" aria-live="polite">Revenue updated: 1.2 M</div>`. Throttle to once per 5 s.
- Touch targets for chart controls: 44 px.

## 6. Motion
Entrance animation plays once, never on filter changes, and is off under `prefers-reduced-motion`.

## Checklist
- [ ] Alt text or title + desc
- [ ] Data table or CSV
- [ ] Direct labels, second encoding, no red/green
- [ ] 4.5:1 text, 3:1 marks or outline
- [ ] Keyboard equivalent for every hover
- [ ] Works in dark mode and forced colours
- [ ] Reduced-motion respected
