Treemap
Sizes of many parts of a whole as nested rectangles, grouped and colored by category.
Status: beta. Category: Data display.
import { Treemap } from '@glyphui/ui/chart'
Exports: Treemap.
Notes
- Tiles too small for text show it in the tooltip and the accessible table instead.
- Each group gets one palette color; after five groups, colors are blended rather than repeated.
Treemap props
| Prop | Type | Default | Description |
|---|---|---|---|
category (required) | string | Field naming each rectangle. | |
data (required) | readonly T[] | One row per rectangle. Rows sharing a group are colored and nested together. | |
title (required) | string | ||
value (required) | string | Field holding each rectangle's size. | |
className | string | ||
colors | readonly ChartColorValue[] | ||
description | ReactNode | ||
empty | ReactNode | Shown when there is no data. Defaults to a short "No data" message. | |
error | unknown | Shows an error message in place of the plot, with a retry button when onRetry is set. | |
group | string | Field grouping rectangles, e.g. a team or product line. Each group gets one color. | |
height | number | Plot height in pixels. Default 280. | |
hideTitle | boolean | ||
loading | boolean | Shows a skeleton in place of the plot. | |
onRetry | (() => unknown) | ||
showLegend | boolean | ||
valueFormatter | ((value: number) => string) |
Example: Cloud spend
Vendors grouped by team.
import { Treemap } from '@glyphui/ui/chart'
const spend = [
{ vendor: 'AWS', team: 'Platform', cost: 42800 },
{ vendor: 'Datadog', team: 'Platform', cost: 9400 },
{ vendor: 'Cloudflare', team: 'Platform', cost: 3100 },
{ vendor: 'Snowflake', team: 'Data', cost: 18600 },
{ vendor: 'Fivetran', team: 'Data', cost: 5200 },
{ vendor: 'Figma', team: 'Design', cost: 2900 },
{ vendor: 'Linear', team: 'Product', cost: 1400 },
{ vendor: 'Notion', team: 'Product', cost: 1100 },
]
const usd = (v: number) => `${(v / 1000).toFixed(1)}k`
export default function Example() {
return (
<Treemap
className="w-full"
title="Software spend by team"
description="October, USD"
data={spend}
category="vendor"
value="cost"
group="team"
valueFormatter={usd}
/>
)
}
Live page: https://glyphui.xyz/components/treemap