Skip to main content

LineChart

BasicCharts<co-line-chart>

LineChart shows a trend over time for up to two series, with an optional target band.

import { LineChart } from 'health-components';

Examples​

Showcase​

Storybook

Two Series​

Storybook

Token Colour​

Storybook

Usage​

<LineChart title="A1c (%)" labels={dates} series={[{ name: "A1c", values: a1c }]} band={[4, 7]} min={4} max={10} />

When to use​

  • A1c over a year, weekly visit volume, days in A/R.

When not to use​

  • Categories without order: BarChart.

Variants and states​

VariantWhat it is
one seriesprimary.
two seriesSecond is accent and dashed, so they differ by more than hue.
bandTarget range shaded in success-soft.

Accessibility​

  • role img with every value in the label; points are drawn as circles too.

Do and don't​

  • Do: A1c with the 4.0 to 7.0 target band.
  • Don't: More than two series.

Props​

PropTypeDefaultDescription
labels *string[]—X-axis labels, one per value
series *LineChartSeries[]—Array<{name, values: number[], color?}>; up to two series read well (the second is dashed)
titlestringnoneCaption above the chart and start of the accessible summary
heightnumber180Height of the drawing in viewBox units (the chart scales with its width)
minnumber0Bottom of the scale
maxnumberauto (largest value)Top of the scale
band[number, number]none[low, high] target band

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-line-chart>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-line-chart title="…" height="…" [labels]="labels"></co-line-chart>
KindNameDescription
property / JSON attributelabelsX-axis labels, one per value
property / JSON attributeseriesArray<{name, values: number[], color?}>; up to two series read well (the second is dashed)
attributetitleCaption above the chart and start of the accessible summary; default none
attributeheightHeight of the drawing in viewBox units (the chart scales with its width); default 180
attributeminBottom of the scale; default 0
attributemaxTop of the scale; default auto (largest value)
property / JSON attributeband[low, high] target band; default none
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus