# Area chart

A value over time as filled areas, one or several series, with a legend, tooltip and data table.

- Family: charts
- Import: `import { AreaChart } from "@senvenli/react/charts";`
- Page: https://design.senvenli.com/docs/components/area-chart
- JSON: https://design.senvenli.com/docs/components/area-chart.json

## Example: Revenue by channel

Two series over a year, summed by area.

```tsx
import { AreaChart } from "@senvenli/react/charts";

const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const REVENUE = MONTHS.map((month, i) => ({ month, online: 32000 + i * 2400, retail: 18000 + i * 900 }));

export default function Example() {
  return (
    <AreaChart
      title="Revenue"
      period="Jan–Dec 2026"
      data={REVENUE}
      index="month"
      categories={["online", "retail"]}
      labels={{ online: "Online", retail: "Retail" }}
    />
  );
}
```

## Guidelines

### When to use it

- A total and its trend over time.

### Use something else when

- [line-chart](https://design.senvenli.com/docs/components/line-chart.md): Several series are compared, not summed.
- [bar-chart](https://design.senvenli.com/docs/components/bar-chart.md): Periods are compared as discrete values.

## Accessibility

Keyboard:

- Arrow left / right: Moves between data points; the tooltip follows.

Built in:

- A "Show as table" button shows the same data as a table, which screen readers get by default.

You provide:

- A title that says what the figure is.

## API reference

### AreaChart

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| title | `string` |  | no | What the chart shows ("Revenue"), over it; leave it out when a card or a heading already says so. |
| aria-label | `string` |  | no | Names the chart when it has no visible `title` (a card's heading already says what it shows). |
| period | `string` |  | no | The period it covers ("June–September 2026"). |
| total | `React.ReactNode` |  | no | The headline figure, in `metric-medium` ("€ 184,2k"). |
| data | `readonly T[]` |  | yes |  |
| index | `keyof T & string` |  | yes | The x key: the period or category of each row. |
| categories | `readonly (keyof T & string)[]` |  | yes | The series keys, in order; the first is the product's own figure (`ds-chart-1`). |
| labels | `Readonly<Partial<Record<string, string>>>` |  | no | Series names by key ("web" → "Website"); the key by default. |
| valueFormatter | `ChartValueFormatter` |  | no | Shared by axis, tooltip and table (Intl): "€ 48.920". |
| indexFormatter | `(value: unknown) => string` |  | no | The index label in the tooltip and the table ("August 2026"). |
| indexLabel | `string` |  | no | The index column's header in the data table; "Period" for time charts, "Category" for BarChart. |
| height | `number` |  | no | The plot's height in px; 240 by default. |
| isLoading | `boolean` |  | no |  |
| emptyState | `React.ReactNode` |  | no | Shown instead of the plot when there is no data: an `EmptyState size="small"` or text; "No data" by default. |
| allowDecimals | `boolean` |  | no | `false` for whole counts (orders, new customers): the value axis steps by whole numbers, so a small count reads 0 / 1 / 2 / 3, never 0.7 / 1.4 / 2.1. Fractional steps by default. Percent bars keep their 0–100% steps. |
| comparison | `keyof T & string` |  | no | The previous period's key: a dashed `ds-chart-neutral` line without fill. |
| yAxisWidth | `number` |  | no | The value axis' width in px; by default wide enough for its longest tick (48–128px). |
| onValueChange | `(row: T \| null) => void` |  | no | A pointer press on the chart: the row under it (keyboard users read values in the tooltip and the table). |

### Tokens it reads

`--ds-background-neutral`, `--ds-border`, `--ds-border-bold`, `--ds-border-focused`, `--ds-chart-1`, `--ds-chart-2`, `--ds-chart-3`, `--ds-chart-4`, `--ds-chart-5`, `--ds-chart-neutral`, `--ds-link`, `--ds-radius-medium`, `--ds-radius-small`, `--ds-radius-xsmall`, `--ds-shadow-overlay`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-space-300`, `--ds-surface-overlay`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-success`

## Related

- [line-chart](https://design.senvenli.com/docs/components/line-chart.md)
- [bar-chart](https://design.senvenli.com/docs/components/bar-chart.md)
- [sparkline](https://design.senvenli.com/docs/components/sparkline.md)
