Treemap

A flexible and composable treemap built with D3 primitives and React.

Example

Treemap

Visualize hierarchical data using nested rectangles.

Electronics - 1,500Women - 800Men - 600Furniture - 900Accessories - 400
Electronics
Furniture
Clothing
Accessories
classic MODE

Installation

components/charts/Treemap.tsx

How It Works

The Treemap uses d3.hierarchy and d3.treemapto calculate the spatial distribution of nested rectangles. Each leaf node represents a data point, and its area is proportional to its value. The useD3Transition hook ensures smooth transitions when data changes.