Treemap Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Hierarchical treemaps sized by value — clear at a glance, beautiful by default
Installation
Usage
The treemap chart is composible. <EvilTreemapChart> is the container: you pass hierarchical or flat tile data (TreemapNode[]) plus a chartConfig whose keys match each tile’s display name (nameKey). Compose <Tiles /> with behavior flags (isClickable, glowingTiles, showLabels), then <Tooltip /> and <Legend />, optionally with backgroundVariant on the root — only the slots you need.
import {
EvilTreemapChart,
Tiles,
Tooltip,
Legend,
} from "@/components/evilcharts/charts/treemap-chart";<EvilTreemapChart config={chartConfig} data={treemapData} backgroundVariant="dots">
<Tiles isClickable glowingTiles={["mobile"]} showLabels />
<Tooltip />
<Legend isClickable />
</EvilTreemapChart>Interactive Selection
Add isClickable on <Tiles /> (and on <Legend />) so clicks select a tile. Use onSelectionChange on <EvilTreemapChart> — it receives { dataKey, value } | null, where dataKey is the tile name from nameKey and value comes from dataKey (defaults to cumulative size for nested nodes):
<EvilTreemapChart
config={chartConfig}
data={treemapData}
onSelectionChange={(selection) => {
if (selection) {
console.log("Selected:", selection.dataKey, selection.value);
} else {
console.log("Deselected");
}
}}
>
<Tiles isClickable />
<Legend isClickable />
<Tooltip />
</EvilTreemapChart>Loading State
The treemap chart supports loading state. Pass isLoading to show an animated skeleton while data is being fetched.
Examples
Glowing Tiles
API Reference
The chart is composed of several parts. The props below are grouped by the component they belong to.
The root container. It owns hierarchical data (TreemapNode[]), shared tile selection state, loading skeleton behavior, gradient fills, and aspect ratio defaults. Compose visual slots as children.
A configuration slot consumed by <EvilTreemapChart /> — renders nothing alone. Toggle click behavior, glowing filters, and in-tile labels for every rectangle.
The hover tooltip. Hidden automatically while the chart is loading; uses hideLabel.
Tile legend keyed by each config series. Mirrors treemap gradients with optional click-to-select syncing with clickable tiles.