Skip to content

Bar Chart

Vertical bar chart for comparing quantities across categories. Supports single, grouped, and stacked variants.

Preview

Single series

Grouped (2 series)

Stacked

Props

PropTypeDefaultDescription
data{ label: string; values: number[] }[]--Category data points
series{ name: string; color?: string }[]--Series configuration
variant'single' | 'grouped' | 'stacked''single'Bar layout mode
showGridbooleantrueShow horizontal grid lines
heightnumber200Chart height in px

Code example

React

tsx
import { BarChart } from '@thepace/lexicon/components';

<BarChart
  variant="grouped"
  data={[
    { label: 'Q1', values: [24, 18] },
    { label: 'Q2', values: [32, 26] },
    { label: 'Q3', values: [38, 30] },
    { label: 'Q4', values: [42, 35] },
  ]}
  series={[
    { name: 'Revenue' },
    { name: 'Target' },
  ]}
/>

CSS class reference

ClassPurpose
.lex-bar-chart__barsBar container (flex row)
.lex-bar-chart__groupGrouped bars for one category
.lex-bar-chart__barIndividual bar
.lex-bar-chart__bar--s1 through --s5Series colour
.lex-bar-chart__stackStacked bar container
.lex-bar-chart__segmentStacked bar segment

Accessibility

  • Use role="img" with aria-label describing the chart.
  • Provide a hidden data table for screen readers.
  • Bars enlarge slightly or show a tooltip on hover for keyboard/mouse interaction.
  • Use patterns or textures alongside colour for colour-blind users.

Guidelines

Do

  • Use grouped bars for direct comparison between series.
  • Use stacked bars to show composition of a total.
  • Label the Y-axis to give values context.

Don't

  • Don't use more than 3 series in grouped mode — bars become too narrow.
  • Don't use 3D bar effects.
  • Don't start the Y-axis at a non-zero value without clearly indicating it.

Released under the MIT License. A product by the pace.