Skip to content

Line chart

Pro

Lines over time: one subject with a wash under it and others to compare with, read by pointer, finger and keyboard. Not an M3 component (@windmorph/react-pro).

import { LineChart, ChartLegend, ChartTooltip } from '@windmorph/react-pro/charts';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 48 props below

LineChart 24 props

  • placestype readonly ChartPlace[]Required

    The places along the chart, in order: oldest first for time. Each key once.

  • seriestype readonly ChartSeries[]Required

    The series, each with a value for every place (a value that isn't a finite number is read as none). Up to eight are drawn, each in its own colour; any after the eighth are only in a frame's table view. Each key once.

  • subjecttype stringdefault the only series, when there is one

    The series the chart is about, with a wash under its line; the others are drawn to compare with.

  • curvetype "monotone" | "linear"default "monotone" (smooth, never past a value)

    How a line joins its points.

  • entrancetype "rise" | "draw"default "rise"

    How the lines arrive the first time the chart is seen: rising from the baseline, or drawn on from the start (at once under reduced motion).

  • legendtype booleandefault with two or more series

    Shows the legend, whose chips hide and show series.

  • formatValuetype ChartFormatter

    Formats a value in the readout, the table and what assistive technology says.

  • formatAxistype ChartFormatterdefault in full under 10,000 with the decimals the step needs, compact above

    Formats the side labels.

  • minHeighttype numberdefault 240

    The least height of the plot and its place labels, px at the default text size, growing with larger text (so 480px at 200%); the chart grows to the height its container gives it. The legend, when there is one, is above it. Inside a ChartFrame, a chart without it fills the frame's minHeight instead, legend and all (the plot takes the rest, half of it at least), so the frame's placeholder is as tall as the chart.

  • texturetype booleandefault with two or more series

    A pattern per series, a bar's hatch or a line's dashes, so no reader depends on hue (WCAG 1.4.1); false turns it off. Always on in forced colours.

  • placeLabeltype stringdefault labels.place

    Names the places' column in a frame's table view ("Week").

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

  • hiddenSeriestype readonly string[]

    The keys of the series hidden (controlled).

  • defaultHiddenSeriestype readonly string[]default none

    The keys hidden at first (uncontrolled).

Events

  • onHiddenSeriesChangetype ((keys: string[]) => void)

    Called with the keys hidden after a legend chip is pressed.

Text

  • aria-labeltype string

    Names the chart. In a ChartFrame, its title does unless this is given; outside one, give this or aria-labelledby.

  • aria-labelledbytype string

    The id of what names the chart (a frame's title).

  • aria-describedbytype string

    The id of what describes it.

  • aria-detailstype string

    The id of what gives more about it.

  • labelstype Partial<ChartLabels>

    Words it says. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ChartLegend 15 props

  • itemstype readonly ChartLegendItem[]Required

    The series, in the order they are drawn: each one's key, name, colour and mark.

  • hiddenSeriestype readonly string[]

    The keys hidden (controlled), as the charts' hiddenSeries. With it, defaultHiddenSeries or onHiddenSeriesChange, each item is a chip that hides and shows its series.

  • defaultHiddenSeriestype readonly string[]

    The keys hidden at first (uncontrolled).

  • texturetype boolean

    Draws each key's pattern (its slot's, or keyClassName), as the charts draw their marks': on by default once there are two or more items, as on a chart; false turns them off. Forced colours always draw them.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Events

  • onHiddenSeriesChangetype ((keys: string[]) => void)

    Called with the keys hidden after a chip is pressed. The last one shown can't be hidden.

Text

  • aria-labeltype string

    Names the legend, in place of labels.legend ("Series").

  • aria-labelledbytype string

    The ids of what names the legend: a chart's legend is named "Series" and the chart's name.

  • aria-describedbytype string

    The id of what describes the legend.

  • aria-detailstype string

    The id of what gives more about it.

  • labelstype Partial<ChartLabels>

    Words it says. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ChartTooltip 9 props

  • titletype stringRequired

    The place: its full name.

  • rowstype readonly ChartTooltipRow[]Required

    Every series on show at the place, in the legend's order.

  • totaltype { label: string; value: string; }

    The sum, where the series add up, with its word.

  • texturetype boolean

    Draws each key's pattern, as the charts draw their marks': on by default once there are two or more rows, as on a chart; false turns them off. Forced colours always draw them.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • A subject with a wash, and a quiet line to compare with (subject, quiet)

    Built

    Variant · Compare

  • One series alone, with straight joins (curve="linear")

    Built

    Variant · Temperature

  • Values below nought, and a gap where there is no value (null)

    Built

    Configuration · Temperature

  • Figures with a unit (formatValue)

    Built

    Configuration · Temperature

  • In a ChartFrame, with the same numbers in its table view (placeLabel)

    Built

    Use case · Compare

  • A window of live figures moving on, matched by key

    Built

    Use case · Live

  • Built to Material’s data visualisation guidance

    Extension

    M3 has no chart component. This one takes M3’s colour roles, type scale and springs, with eight series colours generated for every built-in theme, mode and contrast level.

  • One keyboard stop

    Extension

    The chart is a slider over its places, a native range input, so the keyboard and a phone’s screen reader read each place with its values.

  • Motion matched by place

    Extension

    New numbers move the lines from where they are on the spatial spring; a place that keeps its key slides, and reduced motion takes the new shape at once.

  • A second value axis

    Not built

    Never two value axes on one plot: two measures on different scales are two charts.

  • Zoom and pan

    Not built

    Not built: an app chooses the places to show, such as a period switch.

Theming & tokens

Set the tokens below on the chart or any ancestor. The draw-on's motion is the line chart's own; its colours, line, points, wash, gridlines and state changes come from the --wm-chart-* set every chart shares. A line chart paints with the colour slots, surface, line-width, point-radius, point-ring, wash-opacity, grid, axis, axis-text, legend-gap, legend-key-corner and the state timing; the ramp, the warning and critical colours and the bar tokens are other charts'.

The slots default to a palette made for each built-in theme, mode and contrast level. For a theme of your own, pass it through withChartColors(createTheme(…)) once, beside where you make it; without that, charts take the baseline theme's slots with your primary as slot 1. The legend's chips are the core's filter chips and the readout is the core's rich tooltip, themed by their own --md-comp-* tokens. className goes on the root; style each part with classNames: legend, legendItem, legendKey, body, plot, marks, line, wash, point, hairline, gridline, valueAxis, placeAxis, tick, readout, readoutTitle, readoutRow, readoutValue, readoutKey, readoutName.

LineChart tokens
VariableDefaultPaints
--wm-line-chart-draw-durationvar(--md-sys-motion-spring-effects-slow-duration)How long a line takes to draw on, with `entrance="draw"`.
--wm-line-chart-draw-easingvar(--md-sys-motion-spring-effects-slow-easing)The easing of the draw-on.
Chart tokens, shared by every chart
VariableDefaultPaints
--wm-chart-color-1var(--_wm-chart-scheme-color-1, var(--_wm-chart-fallback-color-1))Series slot 1, in the order series take them: the theme’s primary, moved into the band that reads as a mark: a line, a bar, a part and its keys.
--wm-chart-on-color-1var(--_wm-chart-scheme-on-color-1, var(--_wm-chart-fallback-on-color-1))A figure printed on slot 1 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-2var(--_wm-chart-scheme-color-2, var(--_wm-chart-fallback-color-2))Series slot 2, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-2var(--_wm-chart-scheme-on-color-2, var(--_wm-chart-fallback-on-color-2))A figure printed on slot 2 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-3var(--_wm-chart-scheme-color-3, var(--_wm-chart-fallback-color-3))Series slot 3, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-3var(--_wm-chart-scheme-on-color-3, var(--_wm-chart-fallback-on-color-3))A figure printed on slot 3 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-4var(--_wm-chart-scheme-color-4, var(--_wm-chart-fallback-color-4))Series slot 4, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-4var(--_wm-chart-scheme-on-color-4, var(--_wm-chart-fallback-on-color-4))A figure printed on slot 4 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-5var(--_wm-chart-scheme-color-5, var(--_wm-chart-fallback-color-5))Series slot 5, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-5var(--_wm-chart-scheme-on-color-5, var(--_wm-chart-fallback-on-color-5))A figure printed on slot 5 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-6var(--_wm-chart-scheme-color-6, var(--_wm-chart-fallback-color-6))Series slot 6, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-6var(--_wm-chart-scheme-on-color-6, var(--_wm-chart-fallback-on-color-6))A figure printed on slot 6 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-7var(--_wm-chart-scheme-color-7, var(--_wm-chart-fallback-color-7))Series slot 7, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-7var(--_wm-chart-scheme-on-color-7, var(--_wm-chart-fallback-on-color-7))A figure printed on slot 7 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-color-8var(--_wm-chart-scheme-color-8, var(--_wm-chart-fallback-color-8))Series slot 8, in the order series take them: a line, a bar, a part and its keys.
--wm-chart-on-color-8var(--_wm-chart-scheme-on-color-8, var(--_wm-chart-fallback-on-color-8))A figure printed on slot 8 (a part's share, a bar's hatch): white or black, whichever reads at 4.5:1 or better.
--wm-chart-step-1var(--_wm-chart-scheme-step-1, var(--_wm-chart-fallback-step-1))Step 1 of the ordered ramp: one hue, lighter to darker in light mode, darker to lighter in dark. Paints the parts of an `ordered` segmented bar or list, spread over the steps.
--wm-chart-on-step-1var(--_wm-chart-scheme-on-step-1, var(--_wm-chart-fallback-on-step-1))A figure printed on step 1: white or black, whichever reads at 4.5:1 or better.
--wm-chart-step-2var(--_wm-chart-scheme-step-2, var(--_wm-chart-fallback-step-2))Step 2 of the ordered ramp: one hue, lighter to darker in light mode, darker to lighter in dark. Paints the parts of an `ordered` segmented bar or list, spread over the steps.
--wm-chart-on-step-2var(--_wm-chart-scheme-on-step-2, var(--_wm-chart-fallback-on-step-2))A figure printed on step 2: white or black, whichever reads at 4.5:1 or better.
--wm-chart-step-3var(--_wm-chart-scheme-step-3, var(--_wm-chart-fallback-step-3))Step 3 of the ordered ramp: one hue, lighter to darker in light mode, darker to lighter in dark. Paints the parts of an `ordered` segmented bar or list, spread over the steps.
--wm-chart-on-step-3var(--_wm-chart-scheme-on-step-3, var(--_wm-chart-fallback-on-step-3))A figure printed on step 3: white or black, whichever reads at 4.5:1 or better.
--wm-chart-step-4var(--_wm-chart-scheme-step-4, var(--_wm-chart-fallback-step-4))Step 4 of the ordered ramp: one hue, lighter to darker in light mode, darker to lighter in dark. Paints the parts of an `ordered` segmented bar or list, spread over the steps.
--wm-chart-on-step-4var(--_wm-chart-scheme-on-step-4, var(--_wm-chart-fallback-on-step-4))A figure printed on step 4: white or black, whichever reads at 4.5:1 or better.
--wm-chart-step-5var(--_wm-chart-scheme-step-5, var(--_wm-chart-fallback-step-5))Step 5 of the ordered ramp: one hue, lighter to darker in light mode, darker to lighter in dark. Paints the parts of an `ordered` segmented bar or list, spread over the steps.
--wm-chart-on-step-5var(--_wm-chart-scheme-on-step-5, var(--_wm-chart-fallback-on-step-5))A figure printed on step 5: white or black, whichever reads at 4.5:1 or better.
--wm-chart-warningvar(--md-sys-color-warning)A meter close to its limit: its fill and its status mark. Always with words.
--wm-chart-criticalvar(--md-sys-color-error)A meter past its limit: its fill and its status mark. Always with words.
--wm-chart-quietvar(--md-sys-color-outline)The rest ("Other", a ranked list's rest row, always dotted), a quiet series (always patterned) and a trend beside a number.
--wm-chart-surfacevar(--_wm-chart-frame-surface, var(--md-sys-color-surface))The colour a chart is drawn on: the ring around a point, the gap between touching marks. A frame sets it to its container.
--wm-chart-line-width2pxA line’s width, with round joins and caps.
--wm-chart-point-radius4pxA point’s and an end dot’s radius (the dot is twice it across).
--wm-chart-gridvar(--md-sys-color-outline-variant)Gridlines: solid hairlines a step off the surface, never dashed.
--wm-chart-axisvar(--md-sys-color-outline)The baseline, and the hairline at the place being read.
--wm-chart-axis-textvar(--md-sys-color-on-surface-variant)The labels along the side and the bottom.
--wm-chart-legend-gap8pxThe space beside each legend chip, and between the legend and the plot (a chart root’s row gap; a segmented bar’s between its strip and its key). Wrapped rows of chips sit 48px apart top to top, as a chip set’s do, so their touch targets never overlap.
--wm-chart-legend-key-cornervar(--md-sys-shape-corner-extra-small)The corners of a block’s colour key, in a legend, a readout and a segmented list’s rows.
--wm-chart-wash-opacity0.24The wash under a line at its top: its colour fades from here to nothing at the baseline.
--wm-chart-bar-max-thickness24pxThe most a bar is across, so it never fills its slot.
--wm-chart-bar-share0.62How much of its slot a bar takes below that, so bars stay apart.
--wm-chart-bar-cornervar(--md-sys-shape-corner-extra-small)The rounded data end of a bar; its base stays square on the baseline.
--wm-chart-mark-gap2pxThe surface between a stack’s touching bars (a segmented bar’s parts take `--wm-segmented-gap`).
--wm-chart-read-dim-opacity0.45The other places’ marks while one is read: they step back.
--wm-chart-state-durationvar(--md-sys-motion-spring-effects-fast-duration)How long a mark takes to step back, forward, or fade as its series hides.
--wm-chart-state-easingvar(--md-sys-motion-spring-effects-fast-easing)The easing of that change.
--wm-chart-point-ring2pxThe ring of `surface` around a point, so it reads where it crosses a line.