Skip to main content
BarChart
@coinbase/cds-web-visualization@3.4.0-beta.9
A bar chart component for comparing values across categories. Supports horizontal and vertical orientations, stacked bars, and grouped series.
Import
import { BarChart } from '@coinbase/cds-web-visualization'
SourceView source code
Peer dependencies
  • framer-motion: ^10.18.0
Related components
View as Markdown

Basic Example

Bar charts are a useful component for comparing discrete categories of data. They are helpful for highlighting trends to users or allowing them to compare proportions at a glance.

To start, pass in a series of data to the chart.

Loading...

Multiple Series

You can also provide multiple series of data to the chart. Series will have their bars for each data point rendered side by side.

Loading...

Series Stacking

You can also configure stacking for your chart using the stacked prop.

Loading...

You can also configure multiple stacks by setting the stackId prop on each series.

Loading...

Stack Gap

Loading...

Border Radius

Bars have a default border radius of 100. You can change this by setting the borderRadius prop on the chart.

Stacks will only round the top corners of touching bars.

Loading...

Round Baseline

You can also round the baseline of the bars by setting the roundBaseline prop on the chart.

Loading...

Negative Data

Loading...

Missing Bars

You can pass in null or 0 values to not render a bar for that data point.

Loading...

You can also use the BarStackComponent prop to render an empty circle for zero values.

Loading...

Customization

Bar Spacing

There are two ways to control the spacing between bars. You can set the barPadding prop to control the spacing between bars within a series. You can also set the categoryPadding prop to control the spacing between stacks of bars.

Loading...

Minimum Size

To better emphasize small values, you can set the stackMinSize or barMinSize prop to control the minimum size for entire stacks or individual bar. It is recommended to only use stackMinSize for stacked charts and barMinSize for non-stacked charts.

Minimum Stack Size

You can set the stackMinSize prop to control the minimum size for entire stacks. This will only apply to stacks that have a value that is not null or 0. It will proportionally scale the values of each bar in the stack to reach the minimum size.

Loading...

Minimum Bar Size

You can also set the barMinSize prop to control the minimum size for individual bars. This will only apply to bars that have a value that is not null or 0.

Loading...

Multiple Y Axes

You can render bars from separate y axes in one BarPlot, however they aren't able to be stack.

Loading...

Custom Components

Candlesticks

You can set the BarComponent prop to render a custom component for bars.

Loading...

Outlined Stacks

You can set the BarStackComponent prop to render a custom component for stacks.

Loading...

Custom Transitions

You can customize the transition animations for your bar chart using the transition prop. This allows you to control enter, update, and exit animations separately.

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.