Skip to content
peakcharts

HorizontalBarChart

Bars on their side, for long labels and ranked lists.

Signups by channel
Signups by channelClick a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.0103206309412SearchReferralSocialEmailDirectSearch: 412Referral: 268Social: 191Email: 143Direct: 97
Click a mark to pin its value
View data
Signups by channel
LabelValue
Search412
Referral268
Social191
Email143
Direct97
<HorizontalBarChart title="Signups by channel" data={data} />

Usage

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

const data = [
  { label: 'Search', value: 412 },
  { label: 'Referral', value: 268 },
  { label: 'Social', value: 191 },
  { label: 'Email', value: 143 },
  { label: 'Direct', value: 97 },
];

export default function Example() {
  return <HorizontalBarChart title="Signups by channel" data={data} />;
}

Data

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

  • Prefer this over BarChart when labels would collide on the x axis.

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