Bar Chart

Free

Pure-SVG grouped bar chart with vertical/horizontal orientation and animated bars.

</>sv-bar-chart chartbarsvg
import { SvBarChartComponent } from '@styloviz/charts/bar-chart';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Live leaderboard — sorted, sliding

example.htmlAngular
<!-- sort orders the categories by their total; when values change the bars
     slide to their new places. Table, Tab order and (barSelect) keep the input order. -->
<sv-bar-chart-pro [categories]="regions" [datasets]="datasets()" sort="descending" />

Horizontal with title

example.htmlAngular
<sv-bar-chart
  [categories]="months"
  [datasets]="revenue"
  orientation="horizontal"
  title="Revenue by month"
  [height]="320" />

Click to drill down

example.htmlAngular
<sv-bar-chart
  [categories]="months"
  [datasets]="revenue"
  (barSelect)="drillDown($event)" />

When to use

  • Comparing a value across discrete categories (revenue by month, sales by region).
  • You want grouped or stacked series for category comparisons.
  • For trends over a continuous axis, use the Line Chart.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels displayed on the axis.
datasetsBarChartDataset[][]One or more data series.
valuePolicySvValuePolicy'clamp'What to do with a bar this chart cannot draw — a negative value, `NaN`, `Infinity`. This is a zero-based bar chart: height is `(value / axisMax) * plotSize`, and an SVG rect refuses a negative height outright, so such a bar does not look wrong, it is simply absent. - `clamp` (default) — draw it at the baseline, mark it there, and disclose its real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a bar's position is its index within its group, so dropping one value would shift every later bar of that series out from under its own category label. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
orientationBarChartOrientation'vertical'Chart orientation.
titlestring''Chart title.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering and feature options.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override for the chart image. When empty, a concise data summary is generated automatically; the full data is always exposed to assistive tech via a visually-hidden table.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
barSelect{ category: string; series: string; value: number }Emitted when a bar is clicked — for drill-down or selection.

<sv-bar-chart-pro>

Also in this family — SvBarChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels displayed on the axis.
datasetsBarChartDataset[][]One or more data series.
valuePolicySvValuePolicy'clamp'What to do with a bar this chart cannot draw — a negative value, `NaN`, `Infinity`. This is a zero-based bar chart: height is `(value / axisMax) * plotSize`, and an SVG rect refuses a negative height outright, so such a bar does not look wrong, it is simply absent. - `clamp` (default) — draw it at the baseline, mark it there, and disclose its real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a bar's position is its index within its group, so dropping one value would shift every later bar of that series out from under its own category label. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
orientationBarChartOrientation'vertical'Chart orientation.
sortBarChartSort'none'Order the categories by their total across the datasets, and slide the bars to their new places when the values change — a live leaderboard. Ties keep the input order. The data table, the keyboard order and `barSelect` keep the input order; only the picture moves, and the slide is off under `prefers-reduced-motion`.
titlestring''Chart title.
heightnumber320Chart height in px.
barStyleBarChartBarStyle'bar'How each value is drawn: `'bar'`, or `'lollipop'` — a thin stem and a dot, for many categories where bars would be a wall of ink.
optionsBarChartOptions{}Rendering and feature options.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override for the chart image. When empty, a concise data summary is generated automatically; the full data is always exposed to assistive tech via a visually-hidden table.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
barSelect{ category: string; series: string; value: number }Emitted when a bar is clicked — for drill-down or selection.

<sv-cylindrical-column-chart>

Also in this family — SvCylindricalColumnChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis, one per column group.
datasetsBarChartDataset[][]One or more series, drawn side by side as cylindrical columns; each `data` array holds one value per category.
valuePolicySvValuePolicy'clamp'What to do with a column this chart cannot draw — a negative value, `NaN`, `Infinity`. The axis starts at zero, so such a column cannot be drawn as given, and one `NaN` would blank the whole plot. - `clamp` (default) — draw a marked stub at the baseline and disclose the real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a column's position is its index within its group. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.3), `cylinderCapRatio` (default 0.18) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-cylindrical-column-chart-pro>

Also in this family — SvCylindricalColumnChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis, one per column group.
datasetsBarChartDataset[][]One or more series, drawn side by side as cylindrical columns; each `data` array holds one value per category.
valuePolicySvValuePolicy'clamp'What to do with a column this chart cannot draw — a negative value, `NaN`, `Infinity`. The axis starts at zero, so such a column cannot be drawn as given, and one `NaN` would blank the whole plot. - `clamp` (default) — draw a marked stub at the baseline and disclose the real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a column's position is its index within its group. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.3), `cylinderCapRatio` (default 0.18) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-gradient-bar-chart>

Also in this family — SvGradientBarChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis, one per bar group.
datasetsBarChartDataset[][]One or more series, drawn side by side as horizontal gradient bars; set `gradientColors: [start, end]` on a series to override the gradient derived from its `color`.
valuePolicySvValuePolicy'clamp'What to do with a bar this chart cannot draw — a negative value, `NaN`, `Infinity`. This is a zero-based bar chart: height is `(value / axisMax) * plotSize`, and an SVG rect refuses a negative height outright, so such a bar does not look wrong, it is simply absent. - `clamp` (default) — draw it at the baseline, mark it there, and disclose its real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a bar's position is its index within its group, so dropping one value would shift every later bar of that series out from under its own category label. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber360Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid` (default false), `showLabels`, `showLegend`, `showValues` (default true), `barGap` (default 0.3), `barRadius` (default 4), `gradientDirection` (default `'horizontal'`) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-gradient-bar-chart-pro>

Also in this family — SvGradientBarChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis, one per bar group.
datasetsBarChartDataset[][]One or more series, drawn side by side as horizontal gradient bars; set `gradientColors: [start, end]` on a series to override the gradient derived from its `color`.
valuePolicySvValuePolicy'clamp'What to do with a bar this chart cannot draw — a negative value, `NaN`, `Infinity`. This is a zero-based bar chart: height is `(value / axisMax) * plotSize`, and an SVG rect refuses a negative height outright, so such a bar does not look wrong, it is simply absent. - `clamp` (default) — draw it at the baseline, mark it there, and disclose its real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a bar's position is its index within its group, so dropping one value would shift every later bar of that series out from under its own category label. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber360Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid` (default false), `showLabels`, `showLegend`, `showValues` (default true), `barGap` (default 0.3), `barRadius` (default 4), `gradientDirection` (default `'horizontal'`) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-column-drilldown-chart>

Also in this family — SvColumnDrilldownChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Top-level category labels on the X-axis; a drilled-into level shows its own `categories` instead.
datasetsDrilldownDataset[][]Top-level series. A series whose `drilldown` map has an entry for a category makes that column clickable, switching the chart to the sub-level.
valuePolicySvValuePolicy'clamp'What to do with a column this chart cannot draw — a negative value, `NaN`, `Infinity` — at whichever level is showing. Hiding such a column would also hide its drill-down, and one `NaN` would blank the axis. - `clamp` (default) — draw a marked stub at the baseline and disclose the real value under the plot. - `reject` — refuse the level and show the error state. `omit` is not available: a column's position is its category index. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
rootTitlestring'Root'Label of the first breadcrumb, which stands for the top level and stays visible while drilled down.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 6) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-column-drilldown-chart-pro>

Also in this family — SvColumnDrilldownChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Top-level category labels on the X-axis; a drilled-into level shows its own `categories` instead.
datasetsDrilldownDataset[][]Top-level series. A series whose `drilldown` map has an entry for a category makes that column clickable, switching the chart to the sub-level.
valuePolicySvValuePolicy'clamp'What to do with a column this chart cannot draw — a negative value, `NaN`, `Infinity` — at whichever level is showing. Hiding such a column would also hide its drill-down, and one `NaN` would blank the axis. - `clamp` (default) — draw a marked stub at the baseline and disclose the real value under the plot. - `reject` — refuse the level and show the error state. `omit` is not available: a column's position is its category index. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
rootTitlestring'Root'Label of the first breadcrumb, which stands for the top level and stays visible while drilled down.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 6) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-range-column-chart>

Also in this family — SvRangeColumnChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis.
datasetsRangeChartDataset[][]One or more range series — each data point has `{ low, high }`.
valuePolicySvValuePolicy'omit'What to do with a range this chart cannot draw — a `NaN` or unbounded end, a low below zero (the axis starts at zero, so it would hang outside the plot), or a high below its low. One `NaN` would blank the axis. - `omit` (default) — leave the range out and say how many under the plot. Safe here: every range keeps its own slot, so no other bar moves. - `reject` — refuse the dataset and show the error state.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-range-column-chart-pro>

Also in this family — SvRangeColumnChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis.
datasetsRangeChartDataset[][]One or more range series — each data point has `{ low, high }`.
valuePolicySvValuePolicy'omit'What to do with a range this chart cannot draw — a `NaN` or unbounded end, a low below zero (the axis starts at zero, so it would hang outside the plot), or a high below its low. One `NaN` would blank the axis. - `omit` (default) — leave the range out and say how many under the plot. Safe here: every range keeps its own slot, so no other bar moves. - `reject` — refuse the dataset and show the error state.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
rangeStyleRangeChartStyle'bar'`'bar'`, or `'dumbbell'` — two dots joined by a line, from low to high.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-range-bar-chart>

Also in this family — SvRangeBarChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis.
datasetsRangeChartDataset[][]One or more range series — each data point has `{ low, high }`.
valuePolicySvValuePolicy'omit'What to do with a range this chart cannot draw — a `NaN` or unbounded end, a low below zero (the axis starts at zero, so it would hang outside the plot), or a high below its low. One `NaN` would blank the axis. - `omit` (default) — leave the range out and say how many under the plot. Safe here: every range keeps its own slot, so no other bar moves. - `reject` — refuse the dataset and show the error state.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber360Chart height in px.
rangeStyleRangeChartStyle'bar'`'bar'`, or `'dumbbell'` — two dots joined by a line, from low to high.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-column-placement-chart>

Also in this family — SvColumnPlacementChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis, one per column group.
datasetsBarChartDataset[][]Exactly two datasets: [0] = background (wider), [1] = foreground (narrower).
valuePolicySvValuePolicy'clamp'What to do with a column this chart cannot draw — a negative value, `NaN`, `Infinity`. The axis starts at zero, so a negative height would draw nothing, and one `NaN` would blank the whole plot. - `clamp` (default) — draw a marked stub at the baseline and disclose the real value under the plot. - `reject` — refuse the dataset and show the error state. `omit` is not available: a column's position is its category index. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.25), `barRadius` (default 4), `placementRatio` (foreground width as a fraction of the background, default 0.5) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-negative-stack-chart>

Also in this family — SvNegativeStackChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis, one per bar group.
datasetsBarChartDataset[][]Series stacked out from a centred zero axis: negative values stack leftward and positive values rightward (e.g. a population pyramid).
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber420Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.2), `barRadius` (default 3) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-stacked-bar-chart>

Also in this family — SvStackedBarChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis, one per bar group.
datasetsBarChartDataset[][]Series stacked end to end into one horizontal bar per category; each `data` array holds one value per category.
valuePolicySvValuePolicy'omit'What to do with a segment a stack cannot draw — a negative value, `NaN`, `Infinity`. A stack only adds positive parts, and one `NaN` would blank the axis. - `omit` (default) — leave the segment out and say how many under the plot. Safe here: a segment's place is in its stack, so no other bar moves. - `reject` — refuse the dataset and show the error state. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4), `showStackTotal` and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-axis-label-template-chart>

Also in this family — SvAxisLabelTemplateChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesAxisLabelCategory[][]X-axis categories; each renders its label plus an optional icon, colour swatch and sub-label.
datasetsAxisLabelTemplateDataset[][]Bar series; each `data` array is indexed by category position and drawn as grouped bars.
titlestring''Chart title rendered above the plot; also the base of the generated accessible name and the data table's caption.
heightnumber340Chart height in pixels.
optionsAxisLabelTemplateOptions{}Display options: grid, legend, value labels, bar gap ratio and animation duration.
customClassstring''Extra CSS classes applied to the root wrapper.
ariaLabelstring''Accessible-name override for the plot; otherwise a series summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
barHoverAxisLabelBarEventEmitted when a bar is hovered or keyboard-focused.
barSelectAxisLabelBarEventEmitted when a bar is clicked or activated via keyboard (Enter/Space).

<sv-axis-label-template-chart-pro>

Also in this family — SvAxisLabelTemplateChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesAxisLabelCategory[][]X-axis categories; each renders its label plus an optional icon, colour swatch and sub-label.
datasetsAxisLabelTemplateDataset[][]Bar series; each `data` array is indexed by category position and drawn as grouped bars.
titlestring''Chart title rendered above the plot; also used as the plot's accessible name.
heightnumber340Chart height in pixels.
optionsAxisLabelTemplateOptions{}Display options: grid, legend, value labels, bar gap ratio and animation duration.
customClassstring''Extra CSS classes applied to the root wrapper.
ariaLabelstring''Accessible-name override for the plot; otherwise a series summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
barHoverAxisLabelBarEventEmitted when a bar is hovered or keyboard-focused.
barSelectAxisLabelBarEventEmitted when a bar is clicked or activated via keyboard (Enter/Space).

<sv-multi-level-label-chart>

Also in this family — SvMultiLevelLabelChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Leaf-level category labels shown directly on the axis
levelsMultiLevelAxisLevel[][]Additional grouping levels — level[0] groups categories, level[1] groups level[0], etc.
datasetsMultiLevelDataset[][]Bar series; each `data` array is indexed by leaf category position and drawn as grouped bars.
titlestring''Chart title rendered above the plot; also used as the plot's accessible name.
heightnumber360Chart height in pixels, including the grouped axis-label rows.
optionsMultiLevelLabelOptions{}Display options: grid, legend, value labels, bar gap ratio and animation duration.
customClassstring''Extra CSS classes applied to the root wrapper.
ariaLabelstring''Accessible-name override for the plot; otherwise a series summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
barHoverMultiLevelBarEventEmitted when a bar is hovered or keyboard-focused.
barSelectMultiLevelBarEventEmitted when a bar is clicked or activated via keyboard (Enter/Space).

<sv-live-update-chart>

Also in this family — SvLiveUpdateChartComponent from @styloviz/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
titlestring'Revenue & Expenses'Chart title, rendered in the header and used in the default accessible name.
ariaLabelstring''Accessible-name override for the chart image.
categoriesstring[]['Jan', …, 'Dec']X-axis category labels; each dataset's `data[i]` is plotted against `categories[i]`.
sourcesLiveUpdateSource[][]Switchable data sets, one toggle button each; the bars animate between them and the Y-axis is fixed to the max across all sources. The first source is active on init; an empty array shows the empty state.
optionsLiveUpdateChartOptions{}Height, bar transition duration, corner radius, and value-label/grid/legend toggles — see `LiveUpdateChartOptions`.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-live-update-chart-pro>

Also in this family — SvLiveUpdateChartProComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
titlestring'Revenue & Expenses'Chart title, rendered in the header and used in the default accessible name.
ariaLabelstring''Accessible-name override for the chart image.
categoriesstring[]['Jan', …, 'Dec']X-axis category labels; each dataset's `data[i]` is plotted against `categories[i]`.
sourcesLiveUpdateSource[][]Switchable data sets, one toggle button each; the bars animate between them and the Y-axis is fixed to the max across all sources. The first source is active on init; an empty array shows the empty state.
optionsLiveUpdateChartOptions{}Height, bar transition duration, corner radius, and value-label/grid/legend toggles — see `LiveUpdateChartOptions`.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-stacked-bar-percent-chart>

Also in this family — SvStackedBarPercentChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the Y-axis, one per bar group.
datasetsBarChartDataset[][]Series stacked into one horizontal bar per category, normalised so every bar spans 100 %; each `data` array holds one value per category.
valuePolicySvValuePolicy'omit'What to do with a segment a stack cannot draw — a negative value, `NaN`, `Infinity`. A stack only adds positive parts, and one `NaN` would blank the axis. - `omit` (default) — leave the segment out and say how many under the plot. Safe here: a segment's place is in its stack, so no other bar moves. - `reject` — refuse the dataset and show the error state. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4), `showCategoryTotals` (default true) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-stacked-column-chart>

Also in this family — SvStackedColumnChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis, one per column group.
datasetsBarChartDataset[][]Series stacked bottom to top into one column per category; each `data` array holds one value per category.
valuePolicySvValuePolicy'omit'What to do with a segment a stack cannot draw — a negative value, `NaN`, `Infinity`. A stack only adds positive parts, and one `NaN` would blank the axis. - `omit` (default) — leave the segment out and say how many under the plot. Safe here: a segment's place is in its stack, so no other bar moves. - `reject` — refuse the dataset and show the error state. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4), `showStackTotal` and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

<sv-stacked-column-percent-chart>

Also in this family — SvStackedColumnPercentChartComponent from @styloviz-pro/charts.

Async states

  • loading
  • empty
  • error
  • retry

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the series are being fetched.
errorSvDataError | string | nullnullLoad failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`.
emptyMessagestring'No data to plot'Copy for the empty state.
filteredbooleanfalseWhether a filter, not an absence of data, is why the chart is empty.
categoriesstring[][]Category labels on the X-axis, one per column group.
datasetsBarChartDataset[][]Series stacked into one column per category, normalised so every column spans 100 %; each `data` array holds one value per category.
valuePolicySvValuePolicy'omit'What to do with a segment a stack cannot draw — a negative value, `NaN`, `Infinity`. A stack only adds positive parts, and one `NaN` would blank the axis. - `omit` (default) — leave the segment out and say how many under the plot. Safe here: a segment's place is in its stack, so no other bar moves. - `reject` — refuse the dataset and show the error state. For data that genuinely goes below zero, use `<sv-negative-stack-chart>`.
titlestring''Heading shown above the chart (omitted when empty); also used in the generated accessible name.
heightnumber320Chart height in px.
optionsBarChartOptions{}Rendering options: `showGrid`, `showLabels`, `showLegend`, `showValues`, `barGap` (default 0.35), `barRadius` (default 4), `showCategoryTotals` (default true) and `animationDuration`.
customClassstring''Additional CSS classes on the root element.
ariaLabelstring''Accessible-name override; otherwise a structure summary is generated.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.

Wire it to your API

This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.

Template

Bound to the names this component actually exposes.

usage.htmlAngular
<sv-bar-chart
  [datasets]="datasets()"
  [loading]="loading()"
  [error]="error()"
  [filtered]="filtered()"
  (retry)="load()"
/>

Host class

Drive the three async inputs from your own fetch.

host.component.tsTypeScript
import { signal } from '@angular/core';
import { toSvDataError, type SvDataError } from '@styloviz/core';
import type { BarChartDataset } from '@styloviz/charts/bar-chart';

readonly datasets = signal<BarChartDataset[]>([]);
readonly loading = signal(false);
readonly error = signal<SvDataError | null>(null);
readonly filtered = signal<boolean>(false);

async load(): Promise<void> {
  this.loading.set(true);
  this.error.set(null);
  try {
    const res = await fetch('/api/datasets');
    if (!res.ok) throw res;
    this.datasets.set(await res.json());
  } catch (e) {
    this.error.set(toSvDataError(e));
  } finally {
    this.loading.set(false);
  }
}
  • This component does not emit a query, so it renders what you give it. Call `load()` on your own trigger and bind `datasets`, `loading` and `error`.
  • Set `filtered` when a search or filter is active. It is the difference between "you have no orders" and "no orders match this filter" — telling a customer with 4,000 orders the first one reads as a bug.
  • Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.

Full walkthrough: Connecting to a backend.

Customization & theming

  • Vertical or horizontal orientation.
  • Grouped, stacked and 100%-stacked modes, with each category's absolute total drawn beside its bar on the normalised ones (`showCategoryTotals`, on by default).
  • Animated entrance with configurable colors.
  • Handle `barSelect` for drill-down or selection.
  • `valuePolicy` decides what happens to a bar this chart cannot draw — a negative, `NaN` or `Infinity`. `clamp` (default) draws it as a marked 3px stub at the baseline; `reject` refuses the dataset and shows the error state. `omit` is not offered: a bar's position is its index within its group, so dropping one would slide every later bar out from under its own category label. The cylindrical, placement and drilldown columns take the same `clamp`/`reject` choice. The stacked and range variants default to `omit` instead — a segment or a range keeps its own slot, so leaving one out moves nothing else — and count what they left out under the plot. For data that genuinely goes below zero use `<sv-negative-stack-chart>`.
  • Pro (`sv-bar-chart-pro`): error bars — `errors` on a dataset, a ± per value or `{ minus, plus }` — and `barStyle="lollipop"`, a stem and a dot per value. The range charts take `rangeStyle="dumbbell"`.

Best practices

  • Do: Order categories meaningfully (by value or time), not arbitrarily.
  • Do: Use horizontal orientation when category labels are long.
  • Don't: Don't truncate the value axis baseline away from zero — it distorts comparisons.
  • Do: Leave showCategoryTotals on for the 100 %-stacked variants. Normalising is what those charts are for and also the one thing they hide: every bar is drawn the same length, so two categories look identical when one is ten times the other. The total beside each bar is the only thing in the picture that says which — a tooltip does not count, because the reader who is misled here is precisely the one who thinks the bars are comparable and therefore never hovers.
  • Don't: Do not compare two bars in a 100 % stack by eye and conclude anything about volume. Their lengths are equal by construction. Read the composition off the segments and the magnitude off the total.
  • Tip: The cylindrical columns (`sv-cylindrical-column-chart-pro`) and the gradient bars (`sv-gradient-bar-chart-pro`) are DECORATIVE treatments. The cylinder's caps and shading and the gradient's fade encode nothing — the bar's length is the whole datum, exactly as in the plain bar chart — and they spend ink that carries no data. Use them where the chart is a hero visual on a marketing or summary surface; reach for the plain bar chart where readers compare values closely, and never read a gradient's lighter end as a smaller value.

Accessibility

  • The SVG is a `role="group"` with an auto-generated data summary as its name (override via `ariaLabel`) — `group`, not `img`, because focusable bars inside an `img` are invisible to a screen reader, which prunes its subtree.
  • A bar's height is its value, so `sv-data-summary-table` publishes the numbers beside it: one row per category, one column per series, captioned with the chart title. There is deliberately no overview line above it — the SVG's own name already states the series and the category count, and repeating it is the same sentence twice.
  • Numeric value labels accompany bars; respects reduced-motion for animations.
  • A clamped bar is disclosed three ways, because the stub alone is only visual: a sentence under the plot naming how many bars and their real values, "not drawn to scale" appended to the bar's own `aria-label`, and the same phrase in its table cell. The table keeps the REAL number — it is the data, not a transcript of the drawing.
  • A blank source cell reads as "no value", not `NaN`. `Math.max(10, NaN)` is `NaN`, so a blank read as `NaN` would take the axis, every bar height and every grid tick with it — and SVG drops a `NaN` dimension silently, blanking the plot with no error anywhere.
  • On a 100 %-stacked chart the absolute total is drawn beside every bar, so the magnitude that normalising removes is present as text rather than only in a tooltip. A negative contribution is excluded from the total exactly as it is from the segments, so the caption always equals the sum of what is actually drawn.
  • The Gradient Bar variant publishes the same table. Its bars are not focusable, so a per-bar `aria-label` had nothing to attach to and the SVG's name says only how many series there are — every number on it reached the page as a gradient length and nothing else.
  • The chart accessibility module puts the same table on screen: `svChartDataTable` on the chart, or `provideSvChartA11y({ dataTable: 'toggle' })` for the app, adds a “Show data table” button under the plot (`aria-expanded`, `aria-controls`; the visible table is a named, focusable scroll region). Every chart in the kit supports it.
  • An error range is spoken, not only drawn: “60 (−4, +12)” in the bar's name, its tooltip and its table cell; the whisker itself is `aria-hidden`.

Feedback on Bar Chart

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.