Skip to content
Sign upPro
DataTreemap chartMenu

Treemap chart (Pro)

ProIncluded in $99

Sizes as area, grouped: spend by team and feature, storage by project. Rounded, gapped tiles saturate when pointed at, and a group grows to fill the chart when opened.

ProMarch AI spend by team and feature. Click Engineering to look inside.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/treemap-chart

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { TreemapChart } from "@/components/ui/chatcn/pro/treemap-chart"

<TreemapChart
  title="Where AI spend went in March"
  data={[
    { id: "eng", label: "Engineering", children: [{ id: "agent", label: "Coding agent", value: 9840 }, …] },
    { id: "support", label: "Support", children: […] },
  ]}
  valueFormat="currency"
/>

// Leaves with previous, tinted green or red by how far they moved
<TreemapChart data={withPrevious} colorBy="change" increase="bad" valueFormat="currency" />

A squarified layout keeps tiles close to square so areas compare honestly. Tiles are rounded with a 2 px gap, and groups sit twice as far apart under their name and total. Each group takes a palette color and its items are calm tints of it; point at a tile and it saturates, its group is outlined and everything else steps back, with a tooltip card of its amount, its share of the group and of the total. Labels appear only where they fit: the amount drops before the name shortens, and a number is never cut. The headline is the total in view. Click a group, or press Enter, to look inside: it grows from where it sat to fill the chart and the labels fade in once it settles; the breadcrumb, Escape or Backspace zoom back out the same way. With previous on the leaves, colorBy="change" tints tiles green or red by how far they moved and says the change in each tile, the headline, the tooltip and the table; increase="bad" flips the tones for spend. One level of data works too.

Examples

States

ProOne level of storage by kind, and loading.

Props

PropTypeNotes
dataTreemapItem[]{ id, label, value?, children? }; groups sum their children
title, descriptionReactNodeThe caption
headlineReactNodeDefault: the total in view. null hides it
colorBy"group" | "change"Default group. change tints by the move since previous on each leaf
increase"good" | "bad"Whether growth reads green (default) or red
unit, valueFormatHow amounts read
heightnumberDefault 320
loading, error, onRetry
labelsPartial<TreemapChartLabels>Every string, for translation

Keyboard

KeyAction
TabFocus the chart; the first tile is read out
Arrow keysMove to the nearest tile in that direction
EnterLook inside the tile's group
Escape, BackspaceBack to all

Accessibility

  • The chart is an image summarized with the total and the largest tile, with a table of every item.
  • The breadcrumb is a real button.
  • The readout says the amount and share of whatever is pointed at or focused.

Motion

Tiles fade in once over 560 ms. Looking inside a group grows it from its place over 420 ms with the kit's ease out, by transform, and zooming out shrinks the overview back the same way; labels fade in as it settles. Pointing eases tile colors over 200 ms. Under reduced motion all of it is instant.