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

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...

Data

Negative

Loading...

Null

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...

Range

You can pass in [min, max] tuples as data points to render bars that span a range of 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 stacked.

Loading...

Custom Components

Outlined Stacks

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

Loading...

Animations

You can configure chart transitions using the transitions prop.

Customized Transitions

You can pass in a custom spring based transition to your BarChart for a custom update transition.

Loading...

Disable Animations

You can also disable animations by setting the animate prop to false.

Loading...

Composed Examples

Candlesticks

You can render a candlestick chart by setting the BarComponent prop to a custom candlestick component.

Loading...

Monthly Sunlight

You can combine custom and BarPlot components and transitions to create a springy sunlight chart.

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.