Charts
Line chart
Several series over time.
Usage
LineChart compares a few series over an ordered x axis. Click a legend item to hide a series; the last visible one cannot be hidden.
| month | Revenue | Expenses |
|---|---|---|
| Jan | $18,400 | $12,100 |
| Feb | $20,250 | $12,900 |
| Mar | $19,600 | $14,300 |
| Apr | $23,100 | $13,800 |
| May | $25,800 | $15,200 |
| Jun | $24,900 | $16,700 |
| Jul | $28,300 | $16,100 |
| Aug | $30,100 | $17,400 |
| Sep | $29,400 | $18,900 |
| Oct | $32,800 | $18,200 |
| Nov | $35,600 | $19,800 |
| Dec | $38,900 | $21,300 |
When to use
- Comparing several series over time without the weight of filled areas.
- Values where the exact path matters (latency, price, temperature).
Not for: parts of a whole (use a donut) or comparing unordered categories (use bars).
Curves
monotone (default) smooths the line without ever drawing a peak higher than the data. linear joins points with straight segments and step holds each value until the next.
| hour | p50 latency | p95 latency |
|---|---|---|
| 00:00 | 112ms | 240ms |
| 03:00 | 104ms | 218ms |
| 06:00 | 118ms | 262ms |
| 09:00 | 146ms | 388ms |
| 12:00 | 171ms | 452ms |
| 15:00 | 158ms | 410ms |
| 18:00 | 139ms | 331ms |
| 21:00 | 121ms | 275ms |
API
LineChart
| Prop | Type | Default | Description |
|---|---|---|---|
| data | Record<string, unknown>[] | — | One record per x position. Missing values leave a gap in the line. |
| index | string | — | Key of the x value in each record. |
| series | { key, label?, color? }[] | — | color is 'series-1'…'series-6' or any CSS colour. |
| curve | 'monotone' | 'linear' | 'step' | 'monotone' | Line interpolation. |
| height | number | 280 | Plot height in px. |
| valueFormat | 'number' | 'currency' | 'percent' | 'compact' | Intl options | (n) => string | 'number' | 'percent' expects 0–100 values; pass { style: 'percent' } for fractions. |
| indexFormat | (value, i) => string | — | Formats the x value everywhere. |
| xAxis / yAxis | boolean | options | true | yAxis options: format, ticks, width, domain: [min, max]. |
| grid | boolean | 'horizontal' | 'vertical' | 'both' | true | Dashed grid lines. |
| legend | 'top' | 'bottom' | false | bottom when there are 2+ series | Clicking an item toggles its series. |
| tooltip | boolean | { labelFormat } | true | Snaps to the nearest point. |
| animate | boolean | true | Draw-in and data transitions. |
Keyboard
| Key | Action |
|---|---|
| Tab | Focuses the chart (then the legend buttons). |
| ← / → | Moves the active point. |
| Home / End | First or last point. |
| Esc | Clears the active point. |
| Enter / Space | On a legend item: hides or shows the series. |
Accessibility
- role="img" with an aria-label summary, plus a visually hidden table of every value.
- Legend items are toggle buttons (aria-pressed).
- The tooltip is a visual aid; keyboard users hear the same text through a polite live region.
Motion
- Lines draw in over 600ms with ease-out, staggered by 40ms per series.
- The crosshair glides in 160ms; the tooltip in 120ms.
- Reduced motion removes the draw-in and glide.