Skip to content
Calm motion: animations on this site only fade, with no movement

Treemap ​

Part-to-whole as nested rectangles, with drill-down

One rectangle per item, sized by its value, grouped into the things that contain them: disk use, a budget, traffic by section, a bundle. It answers "what takes up the space?" at a glance. For a few parts of one total, a MeterGroup is clearer. For a trend, Sparkline. For exact numbers, a DataTable.

Repository size

Last picked: nothing yet

  • data is a tree of { id, label, value?, children?, color? }. A leaf's size is its value. A group's is the sum of what it holds. Items with no size are left out. Tiles are squarified so they stay near square and readable.
  • Click or press Enter on a group to open it. The path above (v-model:path, ids from the top) shows where you are. Any step of it goes back, and Backspace goes up one level. A leaf only emits select.
  • Keyboard: one tile is in the tab order. arrow keys move to the nearest tile that way, Home / End jump. Every tile is named with its label, size, share of the level and whether it holds more: readable even when the tile is too small to print its text.
  • Each top-level node gets one chart color and everything inside it keeps it. Set color on a node (a token name or any CSS color) to choose. Tiles are tinted, never solid, so their text keeps its contrast.
  • It fills the width and is height px tall. It re-lays out as the width changes. format puts units on sizes.

Usage ​

ts
import { BlessTreemap } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
data*TreemapNode[]—
heightnumber320
format((v: number) => string)—text for a size, e.g. `(v) => v + " MB"`
labelstring"All"name of the top level in the path, and of the whole chart for screen readers
labelsPartial<{ tile: (label: string, value: string, share: string, children: number) => string; path: string; up: string; hint: string; }>—
pathstring[][]ids from the top down to the level being shown

Events

NamePayloadDescription
select[node: TreemapNode, path: string[]]
update:path[value: string[]]

Released under the MIT License. Character names and artwork belong to their owners.