Treemap
Source: Data Visualisation Catalogue - Treemap


Why This Belongs In The Compiler Gallery
The catalogue describes treemaps as hierarchical rectangles where area encodes quantity. The compiler now executes a flat squarified treemap transform and renders the output with rect/text glyphs. This chart is important because it proves the compiler can own non-axis-aligned layout that still compiles to basic rectangles.
Data Contract
Each raw data row represents a node in a hierarchy.
| Field | Type | Purpose |
|---|---|---|
id | text | Node identity. |
parentId | text or null | Parent node identity; still a follow-up for nested hierarchy support. |
label / category | text | Display label. |
value / revenue | quantitative | Area measure for leaf nodes or categories. |
x | quantitative, derived | Tile x position. |
y | quantitative, derived | Tile y position. |
width | quantitative, derived | Tile width. |
height | quantitative, derived | Tile height. |
share | quantitative, derived | Tile share of the total. |
depth | ordinal, derived | Hierarchy depth; future nested output. |
Expected Visual
The faithful catalogue version should use nested rectangles. Parent rectangles contain child rectangles, and each rectangle's area is proportional to its value relative to siblings. Labels appear inside sufficiently large tiles. The catalogue notes that squarified tiling is common because it keeps rectangles closer to square.
| Element | Expected treatment |
|---|---|
| Tiles | Rects sized by value and nested by hierarchy. |
| Parent/child relation | Child tiles must be spatially contained within parent bounds. |
| Color | Category or depth color. |
| Labels | Only show labels when tile area can contain them cleanly. |
| Gaps | Thin gutters or strokes separate sibling tiles. |
Compiler Mapping
| Compiler part | Mapping |
|---|---|
| Data source | nodes raw hierarchy and tiles layout output. |
| Transform | treemap computes flat squarified tile geometry from raw metric rows. |
| Scales | color: ordinal for category/depth; no x/y scale needed when tile geometry is precomputed. |
| Layers | rect tiles, text labels, optional text values. |
| Interaction | Tile hover should expose label, value, parent path, depth, and source rows. |
Faithfulness Notes
The current gallery treemap no longer precomputes tile geometry in the spec. The remaining faithfulness gap is nested hierarchy: parent/child containment, depth-specific gutters, and label hiding for small tiles should be added before treating treemap as a complete hierarchy family.