Bar Chart

Free

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

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

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

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.
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-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 used to be drawn as a silent sliver (or, for `NaN`, 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 used to be drawn as a silent sliver (or, for `NaN`, 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. Such a column used to be hidden outright (and a drillable one became unreachable), and one `NaN` blanked 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. Such a column used to be hidden outright (and a drillable one became unreachable), and one `NaN` blanked 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 hung outside the plot), or a high below its low. Such ranges used to be drawn wrong without a word, and one `NaN` blanked 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 hung outside the plot), or a high below its low. Such ranges used to be drawn wrong without a word, and one `NaN` blanked 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-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 hung outside the plot), or a high below its low. Such ranges used to be drawn wrong without a word, and one `NaN` blanked 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.
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 such a column used to vanish (a negative height draws nothing) or, for `NaN`, 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, so such a segment used to be skipped without a word (and one `NaN` blanked 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-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, so such a segment used to be skipped without a word (and one `NaN` blanked 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, so such a segment used to be skipped without a word (and one `NaN` blanked 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, so such a segment used to be skipped without a word (and one `NaN` blanked 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
  [categories]="data.items()"
  [loading]="data.loading()"
  [error]="data.error()"
  [filtered]="data.filtered()"
  (retry)="data.reload()"
/>

Host class

Drive the three async inputs from your own fetch.

host.component.tsTypeScript
// This component reports its state but does not emit a query, so drive
// it from your own fetch and bind the three async inputs.
readonly items = signal<Row[]>([]);
readonly loading = signal(false);
readonly error = signal<SvDataError | null>(null);

async load(): Promise<void> {
  this.loading.set(true);
  this.error.set(null);
  try {
    this.items.set(await this.api.fetchRows());
  } 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. Fetch on your own trigger and bind `categories`, `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>`.

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.

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 one blank used to 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.

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.