Skip to content
peakcharts

BarChart

Compare one value across a handful of categories.

Revenue by month
Revenue by monthClick a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.021426384JanFebMarAprMayJunJan: 32Feb: 46Mar: 63Apr: 58May: 71Jun: 84
Click a mark to pin its value
View data
Revenue by month
LabelValue
Jan32
Feb46
Mar63
Apr58
May71
Jun84
<BarChart title="Revenue by month" data={data} />

Usage

BarChart.tsx
import { BarChart } from 'peakcharts';
import 'peakcharts/styles.css';

const data = [
  { label: 'Jan', value: 32 },
  { label: 'Feb', value: 46 },
  { label: 'Mar', value: 63 },
  { label: 'Apr', value: 58 },
  { label: 'May', value: 71 },
  { label: 'Jun', value: 84 },
];

export default function Example() {
  return <BarChart title="Revenue by month" data={data} />;
}

Data

data takes { label: string; value: number; color?: string }[]. Input arrays are never mutated and order is preserved.

  • Order is preserved. Negative values are allowed.
  • Set color on a datum to override a single bar.

Every chart also accepts the common props: description, height, color, variant, animate, formatValue and className.