Overview
Treemap diagrams in Sirena visualize hierarchical data using nested rectangles. Each branch of the hierarchy is represented by a rectangle, which is then subdivided by rectangles representing its children. The area of each rectangle is proportional to a specified value dimension.
Treemap diagrams are useful for:
-
Visualizing hierarchical data structures
-
Displaying proportional relationships
-
Showing nested categories and subcategories
-
Analyzing file system structures
-
Representing organizational hierarchies
-
Displaying budget allocations
Syntax specification
Diagram declaration
Treemap diagrams are declared using either the treemap or treemap-beta
keyword:
treemap
<diagram-content>
Or:
treemap-beta
<diagram-content>
Node definitions
Nodes represent elements in the hierarchy:
"Node Label"
"Child Node": value
Where:
-
Indentation (4 spaces) indicates parent-child relationships
-
Labels are enclosed in double quotes
-
Leaf nodes (endpoints) have numeric values
-
Branch nodes (containers) contain other nodes
Hierarchical structure
Use indentation to create nested hierarchies:
treemap-beta
"Level 1"
"Level 2"
"Level 3": 10
"Level 3B": 15
"Level 2B"
"Level 3C": 20
Each level of indentation (4 spaces) represents one level deeper in the hierarchy.
Examples
Basic hierarchy
treemap
"Category A"
"Item A1": 10
"Item A2": 20
"Category B"
"Item B1": 15
"Item B2": 25
This creates a treemap with:
-
Two root categories (A and B)
-
Each category containing two items
-
Items sized proportionally to their values
Multi-level hierarchy
treemap-beta
"Level 1"
"Level 2A"
"Level 3A": 10
"Level 3B": 15
"Level 2B"
"Level 3C": 20
"Level 3D"
"Level 4A": 5
"Level 4B": 5
This demonstrates:
-
Four levels of nesting
-
Mixed depth (some branches deeper than others)
-
Proportional sizing at each level
File system visualization
treemap
title Disk Space Usage
"Documents"
"Work": 250
"Personal": 180
"Archives": 500
"Media"
"Photos": 1200
"Videos": 3500
"Music": 450
"Applications"
"Development": 800
"Productivity": 350
"Games": 1500
This shows:
-
File system hierarchy
-
Proportional space usage
-
Multiple root folders
-
Different category sizes
Budget allocation
treemap-beta
title 2024 Budget Allocation
"Operations"
"Salaries": 500000
"Infrastructure": 200000
"Supplies": 50000
"Research"
"Equipment": 150000
"Personnel": 300000
"Materials": 75000
"Marketing"
"Advertising": 180000
"Events": 120000
"Digital": 90000
This demonstrates:
-
Budget breakdown by department
-
Sub-category allocation
-
Clear title for context
-
Proportional visualization
With custom styling
treemap-beta
title Project Tasks
"Development"
"Critical":::high
"Bug Fixes": 40
"Security": 30
"Normal"
"Features": 50
"Refactoring": 20
"Documentation":::low
"API Docs": 15
"User Guide": 25
classDef high fill:#f96,stroke:#333,stroke-width:3px;
classDef low fill:#6cf,stroke:#333,stroke-dasharray:5 5;
This shows:
-
Custom CSS classes for priority levels
-
Styled rectangles for visual emphasis
-
Mixed styled and default nodes
Features
Proportional sizing
Node areas are automatically calculated proportional to their values or the sum of their children’s values.
Automatic color coding
Nodes at different depth levels receive different colors automatically for visual distinction.
Limitations
Best practices
Use meaningful labels
Give nodes clear, descriptive labels:
%% Good
treemap
"Revenue by Product"
"Software Licenses": 50000
"Consulting Services": 30000
%% Less clear
treemap
"Data"
"A": 50000
"B": 30000
Include titles
Always add a title for context:
%% Good
treemap
title Q4 Sales by Region
...
%% Missing context
treemap
...
Balance depth
Avoid extremely deep hierarchies:
%% Good - 3 levels
treemap
"Continent"
"Country"
"City": 1000
%% Hard to visualize - 6+ levels
treemap
"Level 1"
"Level 2"
"Level 3"
"Level 4"
"Level 5"
"Level 6": 10