4.46.4

Bar Chart

Bar charts are data visualization components for displaying categorical data with rectangular bars.

Demo

API

Tag

Name Description
<aui-barchart> Custom HTML tag

Attributes

Name Value Required Description
data Number[] | Number[][] | String

Sets the data values for the bar chart. Can be a single array of numbers for one dataset, an array of arrays for multiple datasets (grouped bars), or a JSON string representation. For multiple datasets, each inner array represents a separate series of bars.

formattedLabels String[] | String

Optional array of formatted strings to display instead of numeric values. Used in tooltips and value display above bars. If a formatted label is not provided for a data point (null or empty), the numeric value will be displayed instead. Can be an array of strings or a JSON string representation. The formatted labels are shared across all datasets at the same x position.

formattedTotalLabels String[] | String

Optional array of formatted strings to display as the total value at the top of each stack. Only applies when stacked is true. If not provided, the numeric total (sum of all segments) will be displayed. Can be an array of strings or a JSON string representation. The number of formatted total labels should match the number of data points.

colors String[] | String

Optional array of colors for each dataset. Can be provided as an array or JSON string. Colors can be named colors (e.g., "--color-red-medium") or named gradients (e.g., "--gradient-teal-medium"). See Colors and Gradients documentation for available options. For multiple datasets, colors are applied per dataset (cycling through the array if there are more datasets than colors). For a single dataset, the first color is used. If not provided, default gradient colors will be used.

hideLegend Boolean

When true, hides the legend even when there are multiple datasets. Defaults to false, which displays the legend when there are multiple datasets.

hideVerticalAxis Boolean

When true, hides the y-axis labels for vertical (non-horizontal) bar charts. Defaults to false, which displays the y-axis with numeric value labels.

hideBarValues Boolean

When true, hides the value labels displayed above (or beside) each bar. Defaults to false, which shows values/totals above bars. This is independent of tooltips - you can show tooltips (showValuesAsTooltips) with or without bar values.

horizontal Boolean

When true, renders bars horizontally (left to right) instead of vertically. Supports stacking when combined with the stacked property. Values are displayed to the right of horizontal bars.

i18n string

A stringified JSON object which defines a list of localized strings. The keys must be one of the string IDs defined below.

labels String[] | String

Sets the labels for each x-axis datapoint. Required. Can be an array of strings or a JSON string representation of an array. The number of labels should match the number of data points.

legendLabels String[] | String

Optional array of strings to use as labels for the legend. Only applies when there are multiple datasets (grouped bars). If not provided, default labels will be generated (e.g., "Series 1", "Series 2"). Can be an array of strings or a JSON string representation. The number of legend labels should match the number of datasets.

legendSubLabels String[] | String

Optional array of strings to use as sublabels for the legend, displayed 8px to the right of the primary legend labels. Only applies when there are multiple datasets (grouped bars). When provided, the Chart.js built-in legend is replaced with a custom HTML legend that displays both labels and sublabels. Can be an array of strings or a JSON string representation. The number of legend sublabels should match the number of datasets.

showValuesAsTooltips Boolean

When true, hides the value text above each bar and instead shows a tooltip with the value on hover. When false, values are displayed above each bar. For stacked charts, tooltips are always enabled to show individual segment values.

stacked Boolean

When true, stacks the data series vertically on top of each other. Only applies when there are multiple datasets. The total value is displayed at the top of each stack, and tooltips show individual segment values.

Properties

Name Value Required Description
data Number[] | Number[][] | String

Sets the data values for the bar chart. Can be a single array of numbers for one dataset, an array of arrays for multiple datasets (grouped bars), or a JSON string representation. For multiple datasets, each inner array represents a separate series of bars.

formattedLabels String[] | String

Optional array of formatted strings to display instead of numeric values. Used in tooltips and value display above bars. If a formatted label is not provided for a data point (null or empty), the numeric value will be displayed instead. Can be an array of strings or a JSON string representation. The formatted labels are shared across all datasets at the same x position.

formattedTotalLabels String[] | String

Optional array of formatted strings to display as the total value at the top of each stack. Only applies when stacked is true. If not provided, the numeric total (sum of all segments) will be displayed. Can be an array of strings or a JSON string representation. The number of formatted total labels should match the number of data points.

hideLegend Boolean

When true, hides the legend even when there are multiple datasets. Defaults to false, which displays the legend when there are multiple datasets.

hideVerticalAxis Boolean

When true, hides the y-axis labels for vertical (non-horizontal) bar charts. Defaults to false, which displays the y-axis with numeric value labels.

horizontal Boolean

When true, renders bars horizontally (left to right) instead of vertically. Supports stacking when combined with the stacked property. Values are displayed to the right of horizontal bars.

i18n object

A JSON object which defines a list of localized strings. The keys must be one of the string IDs defined below.

labels String[] | String

Sets the labels for each x-axis datapoint. Required. Can be an array of strings or a JSON string representation of an array. The number of labels should match the number of data points.

legendLabels String[] | String

Optional array of strings to use as labels for the legend. Only applies when there are multiple datasets (grouped bars). If not provided, default labels will be generated (e.g., "Series 1", "Series 2"). Can be an array of strings or a JSON string representation. The number of legend labels should match the number of datasets.

showValuesAsTooltips Boolean

When true, hides the value text above each bar and instead shows a tooltip with the value on hover. When false, values are displayed above each bar. For stacked charts, tooltips are always enabled to show individual segment values.

stacked Boolean

When true, stacks the data series vertically on top of each other. Only applies when there are multiple datasets. The total value is displayed at the top of each stack, and tooltips show individual segment values.

Demo

Tag

Name
<AuiBarchart>

Props

Name Value Required Description
data Number[] | Number[][] | String

Sets the data values for the bar chart. Can be a single array of numbers for one dataset, an array of arrays for multiple datasets (grouped bars), or a JSON string representation. For multiple datasets, each inner array represents a separate series of bars.

formattedLabels String[] | String

Optional array of formatted strings to display instead of numeric values. Used in tooltips and value display above bars. If a formatted label is not provided for a data point (null or empty), the numeric value will be displayed instead. Can be an array of strings or a JSON string representation. The formatted labels are shared across all datasets at the same x position.

formattedTotalLabels String[] | String

Optional array of formatted strings to display as the total value at the top of each stack. Only applies when stacked is true. If not provided, the numeric total (sum of all segments) will be displayed. Can be an array of strings or a JSON string representation. The number of formatted total labels should match the number of data points.

hideLegend Boolean

When true, hides the legend even when there are multiple datasets. Defaults to false, which displays the legend when there are multiple datasets.

hideVerticalAxis Boolean

When true, hides the y-axis labels for vertical (non-horizontal) bar charts. Defaults to false, which displays the y-axis with numeric value labels.

horizontal Boolean

When true, renders bars horizontally (left to right) instead of vertically. Supports stacking when combined with the stacked property. Values are displayed to the right of horizontal bars.

i18n object

A JSON object which defines a list of localized strings. The keys must be one of the string IDs defined below.

labels String[] | String

Sets the labels for each x-axis datapoint. Required. Can be an array of strings or a JSON string representation of an array. The number of labels should match the number of data points.

legendLabels String[] | String

Optional array of strings to use as labels for the legend. Only applies when there are multiple datasets (grouped bars). If not provided, default labels will be generated (e.g., "Series 1", "Series 2"). Can be an array of strings or a JSON string representation. The number of legend labels should match the number of datasets.

legendSubLabels String[] | String

Optional array of strings to use as sublabels for the legend, displayed 8px to the right of the primary legend labels. Only applies when there are multiple datasets (grouped bars). When provided, the Chart.js built-in legend is replaced with a custom HTML legend that displays both labels and sublabels. Can be an array of strings or a JSON string representation. The number of legend sublabels should match the number of datasets.

showValuesAsTooltips Boolean

When true, hides the value text above each bar and instead shows a tooltip with the value on hover. When false, values are displayed above each bar. For stacked charts, tooltips are always enabled to show individual segment values.

stacked Boolean

When true, stacks the data series vertically on top of each other. Only applies when there are multiple datasets. The total value is displayed at the top of each stack, and tooltips show individual segment values.

Skylab React links

General information about using our React package

i18n Strings

ID Description Default value
barchart.emptyMessage

The message displayed when the chart has no data to display.

This chart updates when data arrives

Guidelines

Accessibility

Bar charts should include appropriate ARIA labels and descriptions to make the data accessible to screen readers.

Usage

Bar charts are used to compare values across different categories. They are most effective when displaying discrete data points.

Design

Design resources can be found on the Skylab design documentation site: skylab.avalara.com