Charts guide

Treemap

Nested data laid out as proportional rectangles.

Install

npx shadcn@latest add @foldcn/treemap

Treemap parameters

ParameterType / propsBehavior
dataHierarchyNode | HierarchyNode[]Nested { name, value?, children? } nodes.
dataKey / nameKeystringNumeric value and label fields. Defaults to value / name.
width / heightnumberSVG dimensions.
responsivebooleanFits the SVG to the available width.
padding / nodeInset / nodeGap / aspectRationumberTreemap cell inset, gap, and squarify ratio.
type / content / focusPath / onNodeClickflat | nest / callback / number[] / callbackTreemap rendering and caller-owned drill-down state.
onNodeHover / activeTooltipcallback / { name, value, x, y, color } | nullCaller-owned treemap hover state and tooltip display.
innerRadius / outerRadius / ringPaddingnumberSunburst ring limits and spacing.
cx / cy / startAngle / endAnglenumberSunburst center and angular span.
textOptions{ fill?: string }Sunburst value label color; none hides labels.
title / classNamestringAccessible SVG label and wrapper class.

Uses a squarified rectangle layout with custom content, nested drill-down, and caller-owned pointer-following hover tooltips.

Examples

The first example is open. Expand Source inside an example to view its code. Other examples load when opened.

Measured entrywww/src/views/IndexView/IndexLineChart.tsx
Tree-shaken total906.15 KB
Minified + gzip98.70 KB
recharts512.03 KBd3119.02 KBredux101.13 KBes-toolkit59.85 KBdecimal.js-light48.40 KBimmer27.18 KBreselect

Source data is ported. Visual details or interactions may still differ from Recharts.

View the Recharts example