LineChart

Multi-series line chart with nice ticks, time axis, and hover crosshair.

Import

import { LineChart } from '@matix/charts/line-chart';

Usage

Data for Signups
SeriesXValue
Signups:012.
Signups:119.
Signups:215.
Signups:327.
Signups:424.
Signups:533.

Multiple series

Each series keeps its color by identity, and a legend appears automatically once there are two or more.

Data for Revenue, Cost
SeriesXValue
Revenue:030.
Revenue:145.
Revenue:238.
Revenue:352.
Revenue:461.
Cost:020.
Cost:124.
Cost:222.
Cost:328.
Cost:431.

Time axis

Pass Date x values and the x axis switches to calendar-aware ticks.

Data for p95 latency
SeriesXValue
p95 latency:12/31/2025, 4:00:00 PM120.
p95 latency:1/31/2026, 4:00:00 PM98.
p95 latency:2/28/2026, 4:00:00 PM134.
p95 latency:3/31/2026, 5:00:00 PM110.
p95 latency:4/30/2026, 5:00:00 PM90.

API Reference

PropTypeDefaultDescription
seriesChartSeries[]—One or more series to plot
widthnumber—Controlled layout width; enables deterministic SSR
initialWidthnumber—SSR width hint replaced by client measurement
heightnumber280Plot height in px
curve'straight' | 'curved''curved'Interpolation between points
showXAxisbooleantrueShow the bottom axis
showYAxisbooleantrueShow the left axis
showGridbooleantrueShow horizontal grid lines
showTooltipbooleantrueHover crosshair + tooltip
showLegendbooleantrueLegend (renders only with ≥ 2 series)
animatebooleantrueLeft-to-right reveal on mount; respects reduced-motion
maxPointsnumber—LTTB downsampling budget override
yDomain[number, number]—Force the y domain; out-of-range marks are clipped
formattersChartFormatters—Format values, x values, and series/category labels
labelstring—Accessible description (defaults to series labels)
labelsChartLabels—Screen-reader text of the data table and the legend, for translation
showLabelbooleanfalseRender label as a visible title above the plot
sxStyleXStyles—StyleX style override

Accessibility

  • label provides the concise image name. description adds a richer summary through aria-describedby; consumer-owned text or a visible table can be linked with the aria-describedby prop.
  • Datasets up to 20 rows / 100 cells receive a visually hidden native data table. accessibleData replaces that table with custom React content; pass null to suppress it. labels translates the table text and the legend name. Large series require a consumer-provided summary or table.
  • The chart remains one image target rather than making every point focusable.
  • The legend pairs each palette swatch with a text label. Consumers that require non-color visual differentiation should add that context in description or adjacent content.
  • The series reveal is disabled under prefers-reduced-motion.
  • The pointer tooltip is supplemental; the hidden or consumer-provided data representation carries its values for assistive technology.

Formatting

formatters.value, formatters.x, and formatters.category receive the raw value plus a context containing location (axis, tooltip, label, legend, or accessibility), and where relevant axis, seriesId, and index. Use the context when axes should stay compact while tooltips show currency, units, or greater precision. The same callbacks feed margin calculation and accessible data.

Series palette slots follow input order by default. Set colorIndex (0–7) on a ChartSeries when a series must keep the same token color after insertion or reordering.

Data contract

Each series must use one x-value type (number, Date, or string). Numbers and Dates must be finite and sorted in ascending order. Strings are categories, such as month names: the chart puts them at equal intervals in the order that the data first uses them, and formatters.category formats them. A series must not repeat a category. Non-null y values must be finite. Use null for a gap. Development builds warn with the series id and first invalid index; production does not sort or allocate validation copies.

Server rendering

Pass width for deterministic server-rendered SVG. Use initialWidth when the server has a layout estimate but the chart should become container-responsive after hydration. Without either prop, the wrapper still reserves height, then renders the SVG after ResizeObserver reports a width.