Mermaid Treemap Diagrams
Treemaps visualize hierarchical data as nested rectangles, with size proportional to value. Perfect for showing proportions, file sizes, and hierarchical structures.
Use Case
Use treemaps when you need to:
- Show hierarchical proportions
- Visualize file/directory sizes
- Display category breakdowns
- Show nested data structures
- Compare relative sizes
Code
1```mermaid
2treemap
3 title Project Structure
4 Root
5 Frontend : 40
6 Backend : 35
7 Database : 25
8```
Result:
Examples
Example 1: Project Structure
1```mermaid
2treemap
3 title Codebase Structure
4 Root
5 Frontend : 45
6 Components : 20
7 Pages : 15
8 Utils : 10
9 Backend : 35
10 API : 15
11 Services : 12
12 Models : 8
13 Tests : 20
14 Unit : 12
15 Integration : 8
16```
Result:
Example 2: Budget Allocation
1```mermaid
2treemap
3 title Budget Breakdown
4 Total Budget
5 Development : 50
6 Backend : 25
7 Frontend : 20
8 DevOps : 5
9 Marketing : 30
10 Advertising : 15
11 Content : 10
12 Events : 5
13 Operations : 20
14 Infrastructure : 12
15 Support : 8
16```
Result:
Notes
title- Optional treemap title- Indentation creates hierarchy
- Values determine rectangle size
- Can nest multiple levels
Gotchas/Warnings
- ⚠️ Indentation: Must be consistent for hierarchy
- ⚠️ Values: Should be positive numbers
- ⚠️ Nesting: Can nest multiple levels deep
- ⚠️ Proportions: Rectangle sizes proportional to values
Related Snippets
- Architecture Diagrams (C4 Model)
Create system architecture diagrams using C4 model with Mermaid - Chart.js Bar Chart
Create bar charts for data visualization - Graphviz DOT Diagrams
Create complex graph layouts with Graphviz DOT language - KaTeX Math Examples and Tips
Comprehensive guide to KaTeX math notation with examples and tips - Mermaid Arbitrary Graphs
Create arbitrary graphs and networks with Mermaid - Mermaid Block Diagrams
Create block diagrams for system architecture with Mermaid - Mermaid Charts (Pie, Bar, Line)
Create pie charts, bar charts, and line charts with Mermaid - Mermaid Class Diagrams (UML)
Create UML class diagrams with Mermaid - Mermaid Entity Relationship Diagrams
Create Entity Relationship Diagrams (ERD) with Mermaid - Mermaid Flowchart
Create flowcharts and decision trees with Mermaid - Mermaid Gantt Chart
Create Gantt charts for project timelines and scheduling - Mermaid Git Diagrams
Create Git branch and commit diagrams with Mermaid - Mermaid Kanban Boards
Create Kanban boards for project management with Mermaid - Mermaid Mindmaps
Create mindmaps for brainstorming and organizing ideas with Mermaid - Mermaid Packet Diagrams
Create packet diagrams for network protocols with Mermaid - Mermaid Quadrant Charts
Create quadrant charts for prioritization with Mermaid - Mermaid Radar Charts
Create radar charts for multi-dimensional comparisons with Mermaid - Mermaid Requirement Diagrams
Create requirement diagrams for system requirements with Mermaid - Mermaid Sankey Diagrams
Create Sankey diagrams for flow visualization with Mermaid - Mermaid Sequence Diagram
Create sequence diagrams for interactions and API flows - Mermaid State Diagrams
Create state diagrams and state machines with Mermaid - Mermaid Timeline Diagrams
Create timeline diagrams for chronological events with Mermaid - Mermaid User Journey Diagrams
Create user journey maps with Mermaid - Mermaid ZenUML Diagrams
Create ZenUML sequence diagrams with Mermaid - P5.js Interactive Visualizations
Create interactive visualizations and animations with P5.js