Treemap component visualizes hierarchical data using nested rectangles. The size of each rectangle represents a quantitative value, making it ideal for showing proportions within a hierarchy.
Basic treemap
Flat treemap
type="flat" displays all nodes at once. This is the default type.Nested (interactive) treemap
type="nest" creates an interactive treemap where clicking on a parent node zooms into its children, with breadcrumb navigation.Custom colors
Custom aspect ratio
The
aspectRatio prop controls the shape of rectangles. Lower values create more square-like rectangles. Default is the golden ratio (≈1.618).Custom content renderer
Color panel
Custom name and value keys
Event handlers
Animations
Common pitfalls
- Data structure: Each parent node must have a
childrenarray. Leaf nodes should have a value specified bydataKey. - Automatic values: Parent node values are automatically calculated from children. Don’t manually specify values for parent nodes.
- Name key: Use
nameKeyprop to specify which field contains the display name. Defaults to'name'. - Responsive sizing: Unlike most charts, Treemap doesn’t work well with
responsivemode due to internal dimension calculations. Use fixedwidthandheight. - Tooltip event type: Treemap only supports
'item'tooltip event type. - Deep hierarchies: For deeply nested data, consider using
type="nest"to allow users to explore incrementally.