# Area chart

How an amount changed over time: one series or a stack, each washed down to its base.

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

```tsx
import { Area } from "@arcadia/ui/charts";
```

## When to use

- An amount whose size under the line matters, such as requests served
- Parts of a whole that add up, stacked largest at the base
- A measure that crosses zero, its wash fading toward the zero rule

## When not to use

- A measure that should not start at zero: use `Line`
- A third series beside two overlapping areas: use `Line`

## In context

In Arcadia's products, an area answers an amount's change over time when the amount under the line matters, in a block of its own.

Requests per second in a stack of three regions, the largest at the base.

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

<Chart label="Requests per second" x={DAYS} size="lg">
  <Legend />
  <Grid />
  <YAxis />
  <XAxis />
  <Area stacked label="Europe" values={EUROPE} color={chartColor(1)} />
  <Area stacked label="Americas" values={AMERICAS} color={chartColor(2)} />
  <Area stacked label="Asia" values={ASIA} color={chartColor(3)} />
  <Readout />
</Chart>
```

## Usage

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

<Chart label="Storage used in GB" x={["2026-10-01", "2026-10-02", "2026-10-03"]}>
  <Grid />
  <YAxis />
  <XAxis />
  <Area label="Storage" values={[512, 521, 518]} color={chartColor(1)} />
</Chart>
```

An area shows how an amount changed over time when the amount under the line matters: requests served, storage used. It always starts at zero, because its wash is the value; a measure that should not start at zero is a line.

A plot holds one area, a stack, or two that overlap; a third series is a line. A stack (`stacked` on each of its areas) shows the parts of a whole that adds up, such as requests by region, never a sum that means nothing, such as response times. The largest part sits at the base and the others stack above it by size. Keep a stack to six parts and sum the rest into one named Other, painted `chartColor(7)`.

## Examples

### One series

The wash is the series colour at 28% under the line's highest point, fading to nothing at the baseline.

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

<Chart label="Storage used in GB" x={DAYS}>
  <Grid />
  <YAxis />
  <XAxis />
  <Area label="Storage" values={STORAGE} color={chartColor(1)} />
  <Readout />
</Chart>
```

### Crossing zero

Above and below the solid zero rule, the wash fades toward zero, in the one colour of its series.

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

<Chart label="Queue growth per second" x={DAYS}>
  <Grid />
  <YAxis />
  <XAxis />
  <Area label="Growth" values={QUEUE} color={chartColor(3)} />
  <Readout />
</Chart>
```

### A gap in a stack

A row that any part of a stack misses is a gap in every part: the whole is unknown there, so nothing stands in for it.

The Americas did not report on September 24: on that row the card reads No data for them and for the total.

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

<Chart label="Requests per second" x={DAYS}>
  <Legend />
  <Grid />
  <YAxis />
  <XAxis />
  <Area stacked label="Europe" values={EUROPE} color={chartColor(1)} />
  <Area stacked label="Americas" values={GAPPED} color={chartColor(2)} />
  <Area stacked label="Asia" values={ASIA} color={chartColor(3)} />
  <Readout />
</Chart>
```

### In progress

`partialLast` marks the last row as still running: its segment is dashed to a hollow ring and the wash under it sets back, so a value that can still move never reads as final.

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

<Chart label="Storage used in GB" x={DAYS} partialLast>
  <Grid />
  <YAxis />
  <XAxis />
  <Area label="Storage" values={STORAGE} color={chartColor(1)} />
  <Readout />
</Chart>
```

## Accessibility

Each area adds its label, its first and last value and the change to its chart's name, in the order of its stack, and a stack adds its total, so the whole is heard as well as its parts: "Requests per second: 30 days; Europe from 323 to 403, up 25%; Americas from 184 to 300, up 63%; Asia from 116 to 170, up 47%; Total from 623 to 873, up 40%".

With `Readout` the plot is a slider over its rows, and its value text reads the row the way the card does, each part and then the total: "Tue, Oct 6: Europe 403, Americas 300, Asia 170, Total 873".

With `partialLast` the change runs to the last complete row and the name ends on the row in progress, so a value that can still move is never heard as the last one: "Storage used in GB: 30 days, from 150 to 533, up 255%; Tue, Oct 6 in progress".

## API reference

### Area

- `stacked` (`boolean`): On the other stacked areas, the largest at the base.
- `label` (`string`, required): The series' name.
- `values` (`readonly (number | null | undefined)[]`, required): A value per row of `x`; `null` is a gap.
- `color` (`string`, required): The paint of the slot its entity owns: `chartColor(1)`.
- `curve` (`"monotone" | "straight" | "step"`, default `"monotone"`): `straight` for counts and sparse rows, `step` for a level that holds until it changes.
- `format` (`(value: number) => string`): Format this series in the chart name and readout.
- `appearance` (`"compact"`): A 1.5px square-cornered line (and, for an area, a flat, faint wash) for a compact summary beside its figures.
