Component

Line Chart

Multi-series line chart with a hover tooltip that snaps to the nearest x-axis tick.

Installation

import { WrLineChart } from 'ngwr/line-chart';

@Component({ imports: [WrLineChart] })
export class MyComponent {
  protected readonly series = [
    { label: 'Visits', data: [12, 18, 9, 22, 30, 27, 35] },
    { label: 'Signups', data: [3, 5, 4, 8, 11, 9, 14], color: 'var(--wr-color-success)' },
  ];
  protected readonly labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
}

Multi-series

<wr-line-chart [series]="series" [xLabels]="labels" />
  • Visits
  • Signups
MonTueWedThuFriSatSun

API

Inputs of <wr-line-chart>.

NameDescriptionTypeDefault
seriesreadonly WrLineSeries[][]
ariaLabelAccessible name of the chart. The legend carries the series NAMES only — the numbers are nowhere in text — so without this the plot is nothing at all to a screen reader. Falls back to lineChart.label.string | nullnull
xLabelsLabels for the X axis (one per data point).readonly string[][]
heightChart pixel height.number240
showGridShow gridlines + axis ticks.booleantrue
showLegendShow the legend above the chart.booleantrue
showDotsShow dots at each data point.booleantrue

Types

Data shapes used by the inputs and outputs above.

interface WrLineSeries {
  label: string;
  data: readonly number[];
  color?: string;
}
NameDescriptionTypeDefault
WrLineSeriesOne plotted line.interface
labelrequiredLegend label.string
datarequiredY values, evenly spaced along the x axis.readonly number[]
colorCSS color for the stroke.stringpalette