Vesture

Charts

TreemapNew in 0.7.0

Area-proportional rectangles for part-to-whole data with many categories — disk usage, budget breakdowns, portfolio weight. Squarified layout, static SVG.

Treemap

Preview

Gap 4
Radius 6
Engineering: $420kEngineering$420kSales: $260kSales$260kMarketing: $150kMarketing$150kOperations: $120kOperations$120kPeople: $60kPeople$60kFinance: $45kFinance$45kLegal: $20kLegal$20kIT: $12kIT

Click a cell to select it.

Usage

tsx
import { Treemap } from "@vesture/react";

<Treemap
  width={560}
  height={340}
  data={[
    { key: "eng", label: "Engineering", value: 420 },
    { key: "sales", label: "Sales", value: 260 },
    { key: "ops", label: "Operations", value: 120 },
  ]}
  formatValue={(v) => `$${v}k`}
  gap={4}
  cellRadius={6}
  onCellClick={(d) => setSelected(d.key)}
  selectedKey={selected}
/>

Behavior

  • Rectangles are laid out with the squarified algorithm so cells stay close to square, largest first, and tile the whole box exactly. Zero and negative values are dropped.
  • Labels hide automatically on cells smaller than minLabelWidth × minLabelHeight; every cell keeps a native tooltip with its label and value.
  • Color resolves getColor → datum.color → colors[index] (the 8 chart series by default). selectedKey dims every other cell.
  • renderLabel takes over the text of each cell with the cell's rectangle and its percent of the total — good for custom badges or multi-line labels.

Props

PropTypeDefaultDescription
data{ key: string; label: string; value: number; color?: string }[]—Required.
width / heightnumber—Required.
formatValue(value: number) => stringString
colorsstring[]—Cycled by index; default is the chart series palette.
getColor(datum, index) => string—Highest-priority color source.
gapnumber2Px between cells.
cellRadiusnumber0
minLabelWidth / minLabelHeightnumber48 / 22Smallest cell that shows a label.
selectedKeystring—Highlights one cell.
renderLabel(rect, { formatted, percent }) => ReactNode—Custom SVG content inside each cell.
onCellClick(datum) => void—