Skip to content

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.

Revenue by month
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:

ts
const currency = { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }

Area

area adds a wash beneath the line. It is ignored for multiple series.

Revenue by month
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
Revenue by month and region
Category NorthSouthEast
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.

Daily balance, axis fitted to the data
Category Value
Mon€8,120
Tue€8,240
Wed€8,190
Thu€8,310
Fri€8,260
Daily balance, axis from zero
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.

Revenue by month, with two months missing
Category Value
Jan€18,200
Feb€22,400
Mar
Apr€27,600
May€31,200
Jun
Jul€36,400
Aug€34,100

Bare

Revenue by month
Category Value
Jan18,200
Feb22,400
Mar19,800
Apr27,600
May31,200
Jun29,900
Jul36,400
Aug34,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

PropTypeDefaultDescription
dataLineChartDatum[][]One entry per category, in order
seriesChartSeries[]Two or more measures per category
variant'line' | 'area''line'area adds a wash; ignored for multiple series
heightnumber240Rendered height in px; width fills the container
ticksnumber5Target tick count; the axis lands on round numbers
axisbooleantrueDraw the value axis and its gridlines
legendbooleantrueOnly honoured for a single series
zerobooleanfalseForce zero onto the axis
localestringLocale for every number in the chart
formatIntl.NumberFormatOptionsOptions for every number in the chart
labelstringAccessible name for the figure
unstyledbooleanDrop built-in classes
classstringMerged 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

SlotPropsWhen to use it
underlaylayout geometryDraw behind the line — a target band, a shaded period
overlaylayout geometryDraw in front — an annotation, a threshold line

Data shapes

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