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
Two Series
Token Colour
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
| Variant | What it is |
|---|---|
| one series | primary. |
| two series | Second is accent and dashed, so they differ by more than hue. |
| band | Target 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
| Prop | Type | Default | Description |
|---|---|---|---|
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) |
title | string | none | Caption above the chart and start of the accessible summary |
height | number | 180 | Height of the drawing in viewBox units (the chart scales with its width) |
min | number | 0 | Bottom of the scale |
max | number | auto (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>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | labels | X-axis labels, one per value |
| property / JSON attribute | series | Array<{name, values: number[], color?}>; up to two series read well (the second is dashed) |
| attribute | title | Caption above the chart and start of the accessible summary; default none |
| attribute | height | Height of the drawing in viewBox units (the chart scales with its width); default 180 |
| attribute | min | Bottom of the scale; default 0 |
| attribute | max | Top of the scale; default auto (largest value) |
| property / JSON attribute | band | [low, high] target band; default none |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus |