Native Solid 2 fork of solid-recharts (MIT, © Thomas Guehenneux), derived from Recharts (MIT, © recharts). Adapted documentation; neither project endorses this fork.

Treemap

Treemap is a self-contained hierarchical chart that packs a tree of data into nested rectangles. Each rectangle's area is proportional to its data value, making it easy to spot large and small items across hierarchies. It is not placed inside another chart container.

ThemesButtonDialogTablePrimitivesMenuSelectChartsLinePie
() => {
const data = [
{ name: "Themes", children: [{ name: "Button", size: 1302 }, { name: "Dialog", size: 2400 }, { name: "Table", size: 1800 }] },
{ name: "Primitives", children: [{ name: "Menu", size: 3100 }, { name: "Select", size: 2200 }] },
{ name: "Charts", children: [{ name: "Line", size: 1500 }, { name: "Pie", size: 900 }] },
];
return <ResponsiveContainer width="100%" height={300} initialDimension={{ width: 560, height: 300 }}>
<Treemap data={data} dataKey="size" nameKey="name" stroke="var(--color-background)" colorPanel={["var(--accent-9)", "var(--teal-9)", "var(--amber-9)", "var(--crimson-9)", "var(--violet-9)", "var(--gray-9)"]} />
</ResponsiveContainer>;
}

Props

PropTypeDefaultDescription
dataobject[]—Array of top-level nodes; each may have children
dataKeystring | function"value"Key or function to read each node's numeric value
nameKeystring | function"name"Key to read each node's name / label
width, heightnumber | "%"—Fixed size or percentage inside ResponsiveContainer
aspectRationumber0.5*φ (~1.6)Squarified layout aspect ratio target
type"flat" | "nest""flat"Render the whole tree or nested drill-down mode
nodeGapnumber0Space between sibling rectangles
nodeInsetnumber0Padding inside each parent rectangle

The base props follow the Recharts 3.9.2 Treemap API (reference commit b3451050) that solid-recharts tracks; see the Recharts Treemap reference. The next-suite release scope lists selected adaptations, not full Recharts 3.10.1 parity.

Notes

  • Data shape: Each node can have a children property (array of child nodes). Leaf nodes should have a numeric dataKey value; parent nodes' values are rolled up from their children.
  • Animation: Only entry animation is implemented: nodes slide in from the left on mount. Update animation is not ported, and Treemap has no isUpdateAnimationActive prop.
  • nest mode: Set type="nest" to render an interactive treemap where clicking a parent node drills in; a breadcrumb strip at the bottom navigates back up.
  • Tooltip: Treemap supports item-type tooltips; hover a rectangle to see its details.

See also