Charts

Bar Chart

Grouped, stacked, and negative-value variants. Built with D3 scales, animated on mount, responsive by default.

020406080JanFebMarAprMayJun
New Units
Used Units
Service

Usage

import { BarChart } from 'foundry-charts'

const data = [
  { month: 'Jan', new: 42, used: 31, service: 18 },
  { month: 'Feb', new: 55, used: 27, service: 22 },
  // ...
]

const series = [
  { key: 'new', label: 'New Units' },
  { key: 'used', label: 'Used Units' },
  { key: 'service', label: 'Service' },
]

<BarChart
  data={data}
  series={series}
  xKey="month"
  variant="grouped"
  height={300}
/>

Props

PropTypeDefaultDescription
dataBarChartDatum[]Array of data objects. Each object represents one x-axis category.
seriesSeriesConfig[]Which keys to plot. Each entry has key, label, and optional color.
xKeystringThe key in each datum that provides the x-axis label.
variant'grouped' | 'stacked''grouped'Layout variant.
heightnumber320Chart height in pixels. Width is always 100% of the container.
formatY(v: number) => stringformatValueFormatter for y-axis tick labels and tooltip values.
formatX(v: string) => stringOptional formatter for x-axis tick labels.
classNamestringAdditional CSS class on the root element.
styleCSSPropertiesInline styles on the root element.

SeriesConfig

PropTypeDefaultDescription
keystringKey in the data object to read values from.
labelstringHuman-readable label for legend and tooltip.
colorstringOverride the default series color. Any valid CSS color.