Treemap
A composable treemap for showing how a total divides into categories and their parts.
Overview
Use a treemap to show which parts of a large total matter most: spend by service, bundle size by package, or tickets by topic. Each tile's area is proportional to its value, and nested tiles show how a category breaks down. A treemap holds far more items than a pie chart, but area is harder to compare precisely than length, so reach for a bar chart when exact ranking is the question.
Anatomy
Treemap owns the hierarchical data, colors, and loading state. Each top-level node is a category with its own config entry; its children take lighter steps of the same color, ordered by size, so a family of tiles reads as one group. Add Tiles to control radius, gaps, value labels, and drill-down, Legend to name the categories, and Tooltip for each tile's value and its share of its parent.
Accessibility
When ariaLabel is omitted, the generated name gives the total and the largest categories with their values. Labels pick near-black or near-white text from each tile's fill, so they stay readable on light and dark tints. Small tiles hide their labels instead of overflowing; pair the chart with a table when every value must be readable. Drill-down and the tooltip are pointer-operated.
Installation
Usage
The data is an array of nodes. A leaf carries a value; a parent's value is the sum of its children.
import { Treemap, type ChartConfig, type TreemapNode } from "honestui/charts";<Treemap data={data} config={chartConfig}>
<Treemap.Legend />
<Treemap.Tooltip />
<Treemap.Tiles />
</Treemap>Parent tiles get a tinted frame with a header strip naming the group. Turn it off with showParentLabels={false} to draw only the leaves.
Drill Down
With isDrillable, the treemap shows one level at a time. Selecting a tile zooms into it, and a breadcrumb under the chart leads back out. Use it for deep trees, where showing every level at once leaves tiles too small to label.
Flat Data
Nodes without children make a flat treemap: one tile per category. This example uses a single-hue ramp in the config, a larger radius, and wider gaps.
Loading State
Pass isLoading to reserve the layout with neutral tiles and the same loading treatment as the other Honest UI charts.