Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Line Chart
  3. API and Development

Line Chart

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
PropTypeDefault
labelLocalizedMessagerequired
descriptionLocalizedMessage-
categoriesreadonly (LocalizedMessage | DisplayValue)[]required
seriesreadonly LineChartSeries[]required
sparklinebooleanfalse
curveLineChartCurveMonotone
beginAtZerobooleantrue
showValueAxisbooleanfalse
paletteChartPalette | readonly string[]Categorical
showLegendbooleanfalse
legendPositionChartLegendPositionTop
hiddenSeriesreadonly number[] (controlled)-
defaultHiddenSeriesreadonly number[][]
onHiddenSeriesChange(hiddenSeries, details) => void-
showTooltipbooleantrue
formatTooltipTitle(index, category) => LocalizedMessage | DisplayValuethe category
formatTooltipRow(row: LineChartTooltipRow) => LocalizedMessage | DisplayValuename and value
formatValue(value: number) => LocalizedMessage | DisplayValuelocale decimal format
localestringruntime locale
onSelect(selection: LineChartSelection) => voidread-only
className, id, refroot div-
LineChart forwards data-* attributes to the root. It takes no style, role, children or other event handler.
LineChartSeries
FieldTypeDefault
nameLocalizedMessage | DisplayValuerequired
valuesreadonly number[]required
colorCSS color or bare custom property namepalette color for the position
dashedbooleanfalse
fillbooleantrue for a one-series chart, else false
LineChartSelection and LineChartTooltipRow
LineChartSelection is { datasetIndex, index }. LineChartTooltipRow adds value, formattedValue and dataset.
Exports
LineChart, LineChartCurve, ChartLegendPosition, ChartPalette and the types LineChartProps, LineChartSeries, LineChartSelection, LineChartTooltipRow, ChartColor, ChartText and ChartPaletteInput, from @prepared911/ui/line-chart. The root barrel exports the same names.
Props
NameTypeDefaultDescription
categoriesreadonly ChartText[]—Category labels, given once. Every series has one value per category. The labels show on the horizontal axis, and thin out when they would collide.
labelLocalizedMessage—Accessible name of the chart. It names the plot and captions the data table that assistive technology reads. The chart paints no heading; render one beside it if the screen needs one.
seriesreadonly LineChartSeries[]—The lines, in the order callbacks report as datasetIndex.
beginAtZeroboolean—Includes zero on the value axis. Defaults to true.
classNamestring—Classes appended after the generated classes. Put overrides in @layer chroma.overrides.
curveLineChartCurve—How lines run between points. Defaults to {@link LineChartCurve.Monotone}.
defaultHiddenSeriesreadonly number[]—Initial hidden series positions when uncontrolled.
descriptionLocalizedMessage—Longer description of the chart, read after its name: what it shows, or how to explore it with a keyboard.
formatTooltipRow((row: LineChartTooltipRow) => ChartText)—Formats one tooltip row, the whole text beside the series swatch. Defaults to the series name and the formatted value.
formatTooltipTitle((index: number, category: ChartText) => ChartText)—Formats the tooltip heading from the category position and its label. Defaults to the category label.
formatValue((value: number) => ChartText)—Formats a value for axis ticks, end labels, tooltip rows and the data table. Defaults to the runtime locale's decimal format. Return toDisplayValue(...) for data, or a LocalizedMessage when the text carries a unit word.
hiddenSeriesreadonly number[]—Controlled list of hidden series positions. Pair with onHiddenSeriesChange.
idstring—Id of the root element.
legendPositionChartLegendPosition—Legend edge. Defaults to {@link ChartLegendPosition.Top}.
localestring—BCP 47 locale for the default value format. Defaults to the runtime locale.
onHiddenSeriesChange((hiddenSeries: readonly number[], details: ChangeDetails<ChangeReason>) => void)—Called with the next list of hidden series positions when a legend entry is pressed, before it applies. details.cancel() keeps the current list.
onSelect((selection: LineChartSelection) => void)—Called when a series is selected: its active marker is clicked, or Enter or Space is pressed on the keyboard cursor. A click on the plot away from a marker selects nothing. Pass undefined to make the chart read-only.
paletteChartPaletteInput—Series colors. Defaults to {@link ChartPalette.Categorical}. After the last color the order repeats.
refRef<HTMLDivElement>—Ref to the root element.
showLegendboolean—Paints a legend whose entries are buttons that show or hide a series or slice. Defaults to false.
showTooltipboolean—Shows the tooltip on hover and keyboard focus. Defaults to true.
showValueAxisboolean—Paints value axis tick labels and gridline labels beside the plot. Defaults to false.
sparklineboolean—Draws only the lines and their areas, for a small decorative trend such as the MetricCard sparkline slot: no axes, legend, tooltip, markers, keyboard stop or data table, and the chart is one image named by label. It ignores showLegend, showValueAxis, showTooltip, onSelect, description and the formatters. Defaults to false.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Line Chart / Usage
Next
Line Chart / Accessibility
On this page
LineChartSeries
LineChartSelection and LineChartTooltipRow
Exports
Props
Storybook