TreeMap

Visualize hierarchical data as proportional rectangles. Each area represents its value relative to the whole, making patterns in large datasets instantly visible.

Hierarchical Data
Squarified Layout
Animated Entry
Responsive
TypeScript
Tooltips
Click Handlers
Keyboard Accessible

Revenue Breakdown

Tech company revenue segmented by business unit and product line

Loading...
Selected: Click a rectangle to select

Installation

Get started with the TreeMapChart component in just a few steps.

Quick Install
bash
npx mario-charts@latest add treemap-chart
Zero Lock-in Philosophy
The component is fully yours to own, modify, and customize.

Examples

Explore different data shapes and use cases for the TreeMapChart component.

Flat Data - Disk Usage

Simple non-hierarchical data showing proportional disk usage

Loading...

Portfolio Allocation

Multi-level hierarchy showing investment portfolio breakdown by asset class

Loading...

Loading State

Error State

Chart Error
Failed to load category data

Empty State

No Data
There's no data to display

API Reference

Complete TypeScript interface with all available props and configurations.

PropTypeDefaultDescription
datarequired
readonly TreeMapNode[]Array of tree nodes with name, optional value, and optional children
colors
readonly string[]DEFAULT_COLORSArray of colors for top-level categories. Children inherit parent color at reduced opacity.
height
number400Height of the chart in pixels
loading
booleanfalseShow loading skeleton state
error
string | nullnullError message to display
animation
booleantrueEnable entrance animations (scale + opacity stagger)
onClick
(node: TreeMapNode, path: readonly string[]) => voidCallback fired when a rectangle is clicked. Path contains the ancestry from root to clicked node.
className
stringAdditional CSS classes to apply to the container