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

Bar Chart

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
PropTypeDefault
labelLocalizedMessagerequired
descriptionLocalizedMessage-
categoriesreadonly (LocalizedMessage | DisplayValue)[]required
seriesreadonly BarChartSeries[]required
orientationBarChartOrientationVertical
beginAtZerobooleantrue
showValueAxisbooleanfalse
showValueLabelsbooleanfalse
paletteChartPalette | readonly string[]Categorical
showLegendbooleanfalse
legendPositionChartLegendPositionTop
hiddenSeriesreadonly number[] (controlled)-
defaultHiddenSeriesreadonly number[][]
onHiddenSeriesChange(hiddenSeries, details) => void-
showTooltipbooleantrue
formatTooltipTitle(index, category) => LocalizedMessage | DisplayValuethe category
formatTooltipRow(row: BarChartTooltipRow) => LocalizedMessage | DisplayValuename and value
formatValue(value: number) => LocalizedMessage | DisplayValuelocale decimal format
localestringruntime locale
className, id, refroot div-
BarChart forwards data-* attributes to the root. It takes no style, role, children or event handler.
BarChartSeries
FieldTypeDefault
nameLocalizedMessage | DisplayValuerequired
valuesreadonly number[]required
colorCSS color or bare custom property namepalette color for the position
colorsreadonly string[], one color per barthe series color
BarChartTooltipRow
{ datasetIndex, index, value, formattedValue, dataset, category }.
Exports
BarChart, BarChartOrientation, ChartLegendPosition, ChartPalette and the types BarChartProps, BarChartSeries, BarChartTooltipRow, ChartColor, ChartText and ChartPaletteInput, from @prepared911/ui/bar-chart. The root barrel exports the same names (the shared ones once).
Props
NameTypeDefaultDescription
categoriesreadonly ChartText[]—Category labels, given once. Every series has one value per category. A label is never cut with an ellipsis: one that does not fit its band wraps inside it, and a band too narrow to wrap in thins labels, ending on the last category. The full text is always the tooltip title.
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 BarChartSeries[]—The bars, in the order callbacks report as datasetIndex. With several series the bars of a category sit side by side.
beginAtZeroboolean—Includes zero on the value axis. Defaults to true.
classNamestring—Classes appended after the generated classes. Put overrides in @layer chroma.overrides.
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: BarChartTooltipRow) => 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 full 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.
orientationBarChartOrientation—Vertical or horizontal bars. Defaults to {@link BarChartOrientation.Vertical}.
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 beside the plot. Defaults to false.
showValueLabelsboolean—Paints each value at the end of its bar, formatted by formatValue. Room for the labels is reserved automatically. Defaults to false.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Bar Chart / Usage
Next
Bar Chart / Accessibility
On this page
BarChartSeries
BarChartTooltipRow
Exports
Props
Storybook