Charts
ILineChart
A line over ordered categories, in plain SVG with no charting dependency. Hovering anywhere in the plot drops a crosshair on the nearest category and marks the point.
| Category | Value |
|---|---|
| Jan | €18,200 |
| Feb | €22,400 |
| Mar | €19,800 |
| Apr | €27,600 |
| May | €31,200 |
| Jun | €29,900 |
| Jul | €36,400 |
| Aug | €34,100 |
The width fills the container and height (240px by default) is the only dimension you set. locale and format feed one Intl.NumberFormat, used for the ticks and the tooltip alike.
The examples below pass currency as format:
const currency = { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }Area
area adds a wash beneath the line. It is ignored for multiple series.
| Category | Value |
|---|---|
| Jan | €18,200 |
| Feb | €22,400 |
| Mar | €19,800 |
| Apr | €27,600 |
| May | €31,200 |
| Jun | €29,900 |
| Jul | €36,400 |
| Aug | €34,100 |
Several series
- North
- South
- East
| Category | North | South | East |
|---|---|---|---|
| Jan | €8,200 | €5,400 | €3,100 |
| Feb | €9,600 | €6,100 | €3,800 |
| Mar | €9,100 | €7,400 | €4,200 |
| Apr | €11,800 | €8,200 | €5,900 |
| May | €12,600 | €9,100 | €6,400 |
| Jun | €14,200 | €9,800 | €7,100 |
A legend appears automatically from two series up; legend is honoured only for a single series. When series come and go, give each one a slot so its colour stays with the entity.
Where the axis starts
Zero is off by default, unlike IBarChart: the axis is fitted to the data so the shape of the line stays readable.
| Category | Value |
|---|---|
| Mon | €8,120 |
| Tue | €8,240 |
| Wed | €8,190 |
| Thu | €8,310 |
| Fri | €8,260 |
| Category | Value |
|---|---|
| Mon | €8,120 |
| Tue | €8,240 |
| Wed | €8,190 |
| Thu | €8,310 |
| Fri | €8,260 |
Turn zero on when the question is about magnitude rather than movement: the first chart above draws a 2% wobble across the full height of the plot.
Gaps
null is a missing reading, and the line breaks rather than bridging it.
| Category | Value |
|---|---|
| Jan | €18,200 |
| Feb | €22,400 |
| Mar | — |
| Apr | €27,600 |
| May | €31,200 |
| Jun | — |
| Jul | €36,400 |
| Aug | €34,100 |
Bare
| Category | Value |
|---|---|
| Jan | 18,200 |
| Feb | 22,400 |
| Mar | 19,800 |
| Apr | 27,600 |
| May | 31,200 |
| Jun | 29,900 |
| Jul | 36,400 |
| Aug | 34,100 |
For something smaller still — a trend inside a table cell or a stat tile, with no axis, tooltip or crosshair at all — use ISparkline.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | LineChartDatum[] | [] | One entry per category, in order |
series | ChartSeries[] | — | Two or more measures per category |
variant | 'line' | 'area' | 'line' | area adds a wash; ignored for multiple series |
height | number | 240 | Rendered height in px; width fills the container |
ticks | number | 5 | Target tick count; the axis lands on round numbers |
axis | boolean | true | Draw the value axis and its gridlines |
legend | boolean | true | Only honoured for a single series |
zero | boolean | false | Force zero onto the axis |
locale | string | — | Locale for every number in the chart |
format | Intl.NumberFormatOptions | — | Options for every number in the chart |
label | string | — | Accessible name for the figure |
unstyled | boolean | — | Drop built-in classes |
class | string | — | Merged with the built-in classes |
ui | { root?, svg?, grid?, tick?, category?, line?, area?, crosshair?, marker?, markerRing?, tooltip?, tooltipLabel?, tooltipValue?, table? } | — | Per-slot class overrides |
Slots
| Slot | Props | When to use it |
|---|---|---|
underlay | layout geometry | Draw behind the line — a target band, a shaded period |
overlay | layout geometry | Draw in front — an annotation, a threshold line |
Data shapes
interface LineChartDatum {
label: string
value?: number | null
[key: string]: unknown
}
interface ChartSeries {
key: string
name?: string
slot?: number
}The line is hidden from assistive technology and the data is exposed as a table instead, so a screen reader gets the numbers rather than a shape. label names that table.