Skip to content
peakcharts

TreemapChart

Nested rectangles sized by value, for many parts of a whole.

Storage by folder (GB)
Storage by folder (GB)Click a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.Media: 412Media412Backups: 268Backups268Projects: 174Projects174Logs: 91Logs91Archive: 56
Click a mark to pin its value
Media 412Backups 268Projects 174Logs 91Archive 56
View data
Storage by folder (GB)
LabelValue
Media412
Backups268
Projects174
Logs91
Archive56
<TreemapChart title="Storage by folder (GB)" data={data} />

Usage

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

const data = [
  { label: 'Media', value: 412 },
  { label: 'Backups', value: 268 },
  { label: 'Projects', value: 174 },
  { label: 'Logs', value: 91 },
  { label: 'Archive', value: 56 },
];

export default function Example() {
  return <TreemapChart title="Storage by folder (GB)" data={data} />;
}

Data

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

  • Values must be non-negative.
  • Each value is printed on the chart. The treemap helper returns the tiles if you want to draw your own.

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