# Chart

Bar, line and area charts with a matching data table, and gaps where data is missing.

- **Use it for**: Bar, line and area charts with an equivalent data table.
- **Not for**: A single number. Try [Stat](https://unseenui.com/components/stat/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Chart } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Chart variant="bar" title="Build duration" series={series} unit="seconds" source="CI run 42" hiddenSeries={hidden} onSeriesVisibilityChange={requestSelection} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `asOf` | `string` |  |
| `className` | `string` | Added to the root element, after the component's own classes. |
| `error` | `string` |  |
| `formatValue` | `((value: number) => string)` | Trusted application callback returning bounded inert text. |
| `hiddenSeries` | `readonly string[]` |  |
| `locale` | `string` |  |
| `numberFormat` | `Intl.NumberFormatOptions` |  |
| `onSeriesVisibilityChange` | `((hiddenIds: readonly string[]) => void)` |  |
| `points` | `readonly ChartPoint[]` | Supply points OR aligned series. |
| `series` | `readonly ChartSeries[]` |  |
| `showLegend` | `boolean` |  |
| `source` (required) | `string` |  |
| `state` | `"unknown" \| "ready" \| "loading" \| "denied" \| "unavailable" \| "error" \| "stale" \| "streaming"` |  |
| `title` (required) | `string` |  |
| `unit` (required) | `string` |  |
| `variant` | `"area" \| "line" \| "bar"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[GeneratedUI](https://unseenui.com/components/generated-ui/), [AIForm](https://unseenui.com/components/ai-form/), [DataGrid](https://unseenui.com/components/data-grid/), [ClarificationRequest](https://unseenui.com/components/clarification-request/)

Page: https://unseenui.com/components/chart/
