# Line chart

How a measure changed over time: a 2px line per series, monotone by default, broken where a value is missing.

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

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

## When to use

- A measure's change over time: a response time, a queue's length, a rate
- Two series at one weight, on one scale and in one unit
- A level that holds until it changes, drawn as steps

## When not to use

- The amount under the line matters: use `Area`
- A total for each row, such as tokens a day: use `Bars`
- Names that have no order: use `Bars`

## In context

In Arcadia's products, a line answers how a measure changed over time in a block of its own, its value axis kept at every width.

The median response time over a month, on a scale that starts at a round value above zero.

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

<Chart label="Response time per day" x={DAYS} unit="ms" size="lg">
  <Grid />
  <YAxis />
  <XAxis />
  <Line label="Median" values={MEDIAN} color={chartColor(1)} />
  <Readout />
</Chart>
```

## Usage

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

<Chart label="Response time per day" x={["2026-10-01", "2026-10-02", "2026-10-03"]} unit="ms">
  <Grid />
  <YAxis />
  <XAxis />
  <Line label="Median" values={[124, 119, 121]} color={chartColor(1)} />
</Chart>
```

A line shows how a measure changed over time: response times, a queue's length, a rate. When the amount under it matters, such as requests served, use an area; when each row is a total of its own, such as tokens a day, use bars. Never draw a line across names that have no order.

Every series is drawn at one weight, 1.75px, with round joins and caps, and nothing on it fades: the newest value is the one read most. A line may start on a round value above zero, and then its value axis stays at every width.

## Examples

### Curves

`monotone` by default: it passes through every row and never shows a value the data never had. `straight` for counts and sparse rows, `step` for a level that holds until it changes.

- `monotone`: a measure that varies between its rows
- `straight`: a count per month
- `step`: seats in use, a level that holds

### Two series

One scale in one unit; a second unit is a second plot on the same rows, never a second axis. The legend names each line, and the card reads both on a row.

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

<Chart label="Response time per day" x={DAYS} unit="ms">
  <Legend />
  <Grid />
  <YAxis />
  <XAxis />
  <Line label="Median" values={MEDIAN} color={chartColor(1)} />
  <Line label="95th percentile" values={SLOWEST} color={chartColor(2)} />
  <Readout />
</Chart>
```

### Crossing zero

The zero rule turns solid where the values cross it, and the line keeps its one colour on both sides: the sign is its place, never its colour.

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

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

## States

### A gap

A missing row breaks the line, never bridged and never drawn to zero. A value between two gaps is a dot.

No reading on four days: the line breaks at each, and September 19 stands alone.

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

<Chart label="Response time per day" x={DAYS} unit="ms">
  <Grid />
  <YAxis />
  <XAxis />
  <Line label="Median" values={OUTAGE} color={chartColor(1)} />
  <Readout />
</Chart>
```

### One point and all zero

One row is a dot at its value, never a line to a neighbour it does not have. Zero is data: a series of zeros lies on the baseline of a scale from 0 to 1.

- One row
- All zero

### In progress

`partialLast` marks the last row as still running. Its segment is dashed from the last complete row to a hollow ring, and the card says how much of the row has passed.

October 6 is 14 hours in, so its median can still move.

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

<Chart label="Response time per day" x={DAYS} unit="ms" partialLast={{ elapsed: 0.6 }}>
  <Grid />
  <YAxis />
  <XAxis />
  <Line label="Median" values={MEDIAN} color={chartColor(1)} />
  <Readout />
</Chart>
```

### Too many rows

When there are more rows than the plot can show apart, bin them to a coarser period before they reach the chart, and say so in its label: per week instead of per day. The chart draws every row it is given.

## Accessibility

Each line adds its label, its first and last value and the change to its chart's name: "Response time per day: 30 days; Median from 129ms to 111ms, down 14%; 95th percentile from 262ms to 245ms, down 6.5%". With a single series the chart's label names it. A series that goes below zero gives no change, since a percentage of a signed value says nothing.

With `Readout` the plot is a slider over its rows, and its value text reads every line on the row, in full: "Tue, Oct 6: Median 111ms, 95th percentile 245ms". A missing value reads "no data".

With `partialLast` the change runs to the last complete row, and the name ends on the row in progress: "Response time per day: 30 days, from 129ms to 113ms, down 12%; Tue, Oct 6 in progress". On that row the value text says how much has passed: "Tue, Oct 6, in progress, 14h elapsed: Median 111ms".

## API reference

### Line

- `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.
