Implementing Syncfusion React TreeMap
A comprehensive guide for implementing and customizing the Syncfusion React TreeMap component for hierarchical data visualization. The TreeMap displays nested rectangles where area represents data values, supporting multiple hierarchy levels, interactive drill-down, and rich customization.
When to Use This Skill
Use this skill when you need to:
- Install and set up the TreeMap component
- Bind hierarchical or flat data to TreeMap
- Visualize tree-structured data with multiple levels
- Implement drill-down interactions for data exploration
- Apply color mapping strategies (range, equal, desaturation)
- Configure layouts (square, horizontal, vertical, auto)
- Add legends, tooltips, and data labels
- Implement selection and highlight features
- Customize leaf items and label positioning
- Handle accessibility requirements
- Export or print TreeMap visualizations
- Internationalize or apply RTL support
Component Overview
The TreeMap component is a powerful hierarchical data visualization tool that:
- Renders nested rectangles using SVG for scalability
- Supports any number of hierarchy levels
- Provides four layout algorithms for optimal space utilization
- Enables drill-down for exploring nested data
- Offers three color mapping types for data-driven styling
- Includes interactive features: selection, highlight, tooltips
- Supports data labels, legends, and custom templates
- Provides accessibility and internationalization support
When to Choose TreeMap
Choose TreeMap when:
- Visualizing hierarchical data (organizational charts, file systems, category hierarchies)
- Comparing multiple values across categories using area encoding
- Exploring nested categories through drill-down interaction
- Displaying tree-structured data with many items at multiple levels
- Need space-efficient visualization that uses area encoding
Don't use TreeMap for:
- Simple flat data with few items (use Bar/Column charts)
- Time-series data (use Line/Area charts)
- Relationships between entities (use Diagram/Graph)
- Single hierarchy with few nodes (consider alternative layouts)
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installing @syncfusion/ej2-react-treemap
- Package dependencies and setup
- Module injection for features
- Creating your first TreeMap
- Rendering basic hierarchical data
Data Binding & Hierarchies
📄 Read: references/data-binding.md
- Flat vs hierarchical data structures
- Configuring weightValuePath for sizing
- Binding multilevel hierarchies with levels
- Remote data source integration
- Data transformation patterns
Color Mapping Strategies
📄 Read: references/color-mapping.md
- Range-based color mapping (gradient by values)
- Equal value color mapping (categorical colors)
- Desaturation mapping (opacity-based variation)
- Dynamic color assignment
- Choosing color mapping strategies
Layouts and Layout Selection
📄 Read: references/layouts.md
- Square layout (balanced aspect ratio)
- Horizontal layout (left-to-right ordering)
- Vertical layout (top-to-bottom ordering)
- Auto layout (default optimal layout)
- When to use each layout type
Drill-Down and Navigation
📄 Read: references/drilldown.md
- Enabling drill-down with enableDrillDown
- Configuring levels for multi-level exploration
- Drill-down events and callbacks
- Breadcrumb navigation patterns
- Back navigation handling
Leaf Items, Labels & Templates
📄 Read: references/leaf-items-and-labels.md
- Leaf item configuration and styling
- Label positioning (TopLeft, Center, BottomRight, etc.)
- Data label formatting and templates
- Border and fill customization
- Label overflow handling
Legends, Tooltips & Selection
📄 Read: references/legends-tooltips-selection.md
- Creating and configuring legends
- Tooltip templates and styling
- Selection and highlight modes
- Interactive features and events
- Responding to user interactions
Customization, Accessibility & Export
📄 Read: references/customization-accessibility.md
- WCAG compliance and keyboard navigation
- RTL (right-to-left) support
- Internationalization and localization
- Theming and CSS customization
- Print and export functionality
Quick Start Example
import * as React from 'react';
import { TreeMapComponent } from '@syncfusion/ej2-react-treemap';
export function TreeMapDemo() {
const data = [
{ Title: 'USA', State: 'California', Sales: 2830 },
{ Title: 'USA', State: 'Texas', Sales: 2020 },
{ Title: 'USA', State: 'Florida', Sales: 1880 },
{ Title: 'Germany', State: 'Berlin', Sales: 1880 },
{ Title: 'Germany', State: 'Munich', Sales: 1550 },
];
return (
<TreeMapComponent
height="350px"
dataSource={data}
weightValuePath="Sales"
leafItemSettings={{
labelPath: 'State',
colorMapping: [
{ from: 1500, to: 2000, color: '#FF6B6B' },
{ from: 2000, to: 2500, color: '#4ECDC4' },
{ from: 2500, to: 3000, color: '#45B7D1' }
]
}}
/>
);
}
Common Patterns
Pattern 1: Hierarchical Data with Drill-Down
<TreeMapComponent
enableDrillDown={true}
dataSource={data}
weightValuePath="Sales"
>
<LevelsDirective>
<LevelDirective groupPath="Country" />
<LevelDirective groupPath="State" />
<LevelDirective groupPath="City" />
</LevelsDirective>
</TreeMapComponent>
When to use: Exploring multilevel hierarchies with progressive disclosure through drill-down interaction.
Pattern 2: Color-Coded Categories
<TreeMapComponent
equalColorValuePath="Category"
leafItemSettings={{
colorMapping: [
{ value: 'Electronics', color: '#3498db' },
{ value: 'Furniture', color: '#e74c3c' },
{ value: 'Clothing', color: '#2ecc71' }
]
}}
/>
When to use: Categorizing items with distinct colors for quick visual identification.
Pattern 3: Value-Range Color Gradient
<TreeMapComponent
rangeColorValuePath="Sales"
leafItemSettings={{
colorMapping: [
{ from: 0, to: 10000, color: '#90EE90' },
{ from: 10000, to: 50000, color: '#FFD700' },
{ from: 50000, to: 100000, color: '#FF6347' }
]
}}
/>
When to use: Showing magnitude differences through color intensity for performance metrics, sales, or other continuous values.
Key Props and Configuration
| Prop |
Purpose |
Common Values |
dataSource |
Hierarchical or flat data array |
Array of objects |
weightValuePath |
Property path for item sizing |
e.g., 'Sales', 'Count' |
equalColorValuePath |
Property for categorical coloring |
e.g., 'Category', 'Type' |
rangeColorValuePath |
Property for range-based coloring |
e.g., 'Sales', 'Value' |
enableDrillDown |
Enable click-to-drill interaction |
true/false |
layoutType |
Spatial layout algorithm |
'Squarified', 'Horizontal', 'Vertical', 'SliceAndDice' |
height |
Component height |
e.g., '350px', '100%' |
palette |
Array of colors for items |
['#color1', '#color2', ...] |
Common Use Cases
API Reference
This section summarizes the most commonly used TreeMap props, methods, and events. For the complete API with typed models, see the official docs: https://ej2.syncfusion.com/react/documentation/api/treemap/index-default
Important Properties (selected)
dataSource (Array|DataManager) — The data source for TreeMap. Can be flat or hierarchical. Default: null
weightValuePath (string) — Path to numeric value used for sizing each item. Default: null
colorValuePath (string) — Field used for continuous color mapping (range palettes).
equalColorValuePath (string[]) — Field(s) for categorical/equal color mapping.
rangeColorValuePath (string[]) — Field(s) used for range-based color mapping.
leafItemSettings (object) — Configuration for leaf items (e.g., labelPath, colorMapping, border, gap).
levels (LevelSettingsModel[]) — Array of level configuration objects to define grouping and appearance per hierarchy level.
layoutType (string) — Layout algorithm: Squarified (default), SliceAndDiceHorizontal, SliceAndDiceVertical, SliceAndDiceAuto, etc.
enableDrillDown (boolean) — Enable drill-down interaction. Default: false
drillDownView (boolean) — Use drill-down view layout. Default: false
enableBreadcrumb (boolean) — Show breadcrumb when drilling. Default: false
breadcrumbConnector (string) — Separator shown between breadcrumb items.
initialDrillDown (object) — Configure initial drill-down level/state.
enableHtmlSanitizer (boolean) — Sanitize HTML in templates/tooltips. Default: true
enablePersistence (boolean) — Persist component state between reloads. Default: false
enableRtl (boolean) — Enable right-to-left rendering. Default: false
palette (string[]) — Array of palette colors used for fills.
highlightSettings (object) — Highlight configuration and styling.
selectionSettings (object) — Selection configuration (mode, enable, etc.).
legendSettings (object) — Legend configuration (position, title, shape, etc.).
titleSettings (object) — Title and subtitle configuration.
tooltipSettings (object) — Tooltip templates and behavior.
format (string) — Formatting string for labels or values.
useGroupingSeparator (boolean) — Apply grouping separator for numeric values. Default: true
description (string) — Accessibility description for the TreeMap.
margin (object) — Margin settings for the component ({ top, right, bottom, left }).
height / width (string|number) — Size of the component (e.g., 350px or 100%).
theme (string) — Theme name (e.g., Material, Bootstrap).
Common Methods
destroy() — Clean up the TreeMap instance and remove listeners.
export(type, fileName, orientation, allowDownload) — Export the TreeMap as PNG|JPEG|SVG|PDF. Returns a Promise for PDF export flows.
print(id) — Print TreeMap content by element id, DOM element, or array of ids.
doubleClickOnTreeMap(e) — Programmatically trigger double-click behavior.
selectItem(levelOrder, isSelected) — Select or deselect an item by level order array.
Common Events
load / loaded — Lifecycle events fired before/after component load.
itemRendering — Fired while items are rendered; use to customize item appearance.
click / itemClick — Fired on item click.
doubleClick — Fired on item double click.
drillStart / drillEnd — Fired when drill-down starts/ends.
itemHighlight / itemSelected — Events for highlight/selection lifecycle.
legendRendering / legendItemRendering — Events during legend rendering.
tooltipRendering — Fired when tooltip content is prepared.
resize — Fired on component resize.
beforePrint / print — Hooks around printing/export.
Quick Import Example
import { TreeMapComponent, LevelsDirective, LevelDirective, Inject, TreeMapTooltip } from '@syncfusion/ej2-react-treemap';
<TreeMapComponent dataSource={data} weightValuePath="value" enableDrillDown={true}>
<LevelsDirective>
<LevelDirective groupPath="category" />
</LevelsDirective>
<Inject services={[TreeMapTooltip]} />
</TreeMapComponent>
- Organization Hierarchies: Visualize employee counts across departments, regions, and divisions
- File System Browser: Display disk usage by folders and subfolders with drill-down
- Sales Performance: Compare regional sales, product categories, and territories
- Website Analytics: Explore traffic sources, pages, and user segments hierarchically
- Portfolio Allocation: Visualize asset distribution across categories and subcategories
- Market Share: Display competitive landscape with company hierarchies
- Budget Analysis: Allocate and visualize budget across departments and line items
Next Steps
- Start with Getting Started guide to install and render your first TreeMap
- Choose a data binding pattern based on your data structure
- Select color mapping strategy (range, equal, or desaturation)
- Configure layout and drill-down if exploring hierarchies
- Customize leaf items, labels, and tooltips for your use case
- Add interactivity with selection and events
- Ensure accessibility and internationalization requirements
Ready to implement TreeMap? Start with references/getting-started.md or choose a specific feature guide from the navigation options above.
1---2name: syncfusion-react-treemaps3description: Comprehensive guide for implementing Syncfusion React TreeMap component. Use this skill when users need help creating hierarchical data visualizations, configuring drill-down interactions, applying color mapping, working with multiple hierarchy levels, customizing leaf items, or troubleshooting TreeMap data binding and display issues. Covers installation, data binding patterns, layouts, legends, tooltips, selection, accessibility, and advanced customization for interactive hierarchical data exploration.4---5
6# Implementing Syncfusion React TreeMap
7
8A comprehensive guide for implementing and customizing the Syncfusion React TreeMap component for hierarchical data visualization. The TreeMap displays nested rectangles where area represents data values, supporting multiple hierarchy levels, interactive drill-down, and rich customization.
9
10## When to Use This Skill
11
12Use this skill when you need to:
13- Install and set up the TreeMap component
14- Bind hierarchical or flat data to TreeMap
15- Visualize tree-structured data with multiple levels
16- Implement drill-down interactions for data exploration
17- Apply color mapping strategies (range, equal, desaturation)
18- Configure layouts (square, horizontal, vertical, auto)
19- Add legends, tooltips, and data labels
20- Implement selection and highlight features
21- Customize leaf items and label positioning
22- Handle accessibility requirements
23- Export or print TreeMap visualizations
24- Internationalize or apply RTL support
25
26## Component Overview
27
28The **TreeMap** component is a powerful hierarchical data visualization tool that:
29- Renders nested rectangles using SVG for scalability
30- Supports any number of hierarchy levels
31- Provides four layout algorithms for optimal space utilization
32- Enables drill-down for exploring nested data
33- Offers three color mapping types for data-driven styling
34- Includes interactive features: selection, highlight, tooltips
35- Supports data labels, legends, and custom templates
36- Provides accessibility and internationalization support
37
38### When to Choose TreeMap
39
40**Choose TreeMap when:**
41- Visualizing hierarchical data (organizational charts, file systems, category hierarchies)
42- Comparing multiple values across categories using area encoding
43- Exploring nested categories through drill-down interaction
44- Displaying tree-structured data with many items at multiple levels
45- Need space-efficient visualization that uses area encoding
46
47**Don't use TreeMap for:**
48- Simple flat data with few items (use Bar/Column charts)
49- Time-series data (use Line/Area charts)
50- Relationships between entities (use Diagram/Graph)
51- Single hierarchy with few nodes (consider alternative layouts)
52
53## Documentation and Navigation Guide
54
55### Getting Started
56📄 **Read:** [references/getting-started.md](references/getting-started.md)
57- Installing @syncfusion/ej2-react-treemap
58- Package dependencies and setup
59- Module injection for features
60- Creating your first TreeMap
61- Rendering basic hierarchical data
62
63### Data Binding & Hierarchies
64📄 **Read:** [references/data-binding.md](references/data-binding.md)
65- Flat vs hierarchical data structures
66- Configuring weightValuePath for sizing
67- Binding multilevel hierarchies with levels
68- Remote data source integration
69- Data transformation patterns
70
71### Color Mapping Strategies
72📄 **Read:** [references/color-mapping.md](references/color-mapping.md)
73- Range-based color mapping (gradient by values)
74- Equal value color mapping (categorical colors)
75- Desaturation mapping (opacity-based variation)
76- Dynamic color assignment
77- Choosing color mapping strategies
78
79### Layouts and Layout Selection
80📄 **Read:** [references/layouts.md](references/layouts.md)
81- Square layout (balanced aspect ratio)
82- Horizontal layout (left-to-right ordering)
83- Vertical layout (top-to-bottom ordering)
84- Auto layout (default optimal layout)
85- When to use each layout type
86
87### Drill-Down and Navigation
88📄 **Read:** [references/drilldown.md](references/drilldown.md)
89- Enabling drill-down with enableDrillDown
90- Configuring levels for multi-level exploration
91- Drill-down events and callbacks
92- Breadcrumb navigation patterns
93- Back navigation handling
94
95### Leaf Items, Labels & Templates
96📄 **Read:** [references/leaf-items-and-labels.md](references/leaf-items-and-labels.md)
97- Leaf item configuration and styling
98- Label positioning (TopLeft, Center, BottomRight, etc.)
99- Data label formatting and templates
100- Border and fill customization
101- Label overflow handling
102
103### Legends, Tooltips & Selection
104📄 **Read:** [references/legends-tooltips-selection.md](references/legends-tooltips-selection.md)
105- Creating and configuring legends
106- Tooltip templates and styling
107- Selection and highlight modes
108- Interactive features and events
109- Responding to user interactions
110
111### Customization, Accessibility & Export
112📄 **Read:** [references/customization-accessibility.md](references/customization-accessibility.md)
113- WCAG compliance and keyboard navigation
114- RTL (right-to-left) support
115- Internationalization and localization
116- Theming and CSS customization
117- Print and export functionality
118
119## Quick Start Example
120
121```jsx
122import * as React from 'react';
123import { TreeMapComponent } from '@syncfusion/ej2-react-treemap';
124
125export function TreeMapDemo() {
126 const data = [
127 { Title: 'USA', State: 'California', Sales: 2830 },
128 { Title: 'USA', State: 'Texas', Sales: 2020 },
129 { Title: 'USA', State: 'Florida', Sales: 1880 },
130 { Title: 'Germany', State: 'Berlin', Sales: 1880 },
131 { Title: 'Germany', State: 'Munich', Sales: 1550 },
132 ];
133
134 return (
135 <TreeMapComponent
136 height="350px"
137 dataSource={data}
138 weightValuePath="Sales"
139 leafItemSettings={{
140 labelPath: 'State',
141 colorMapping: [
142 { from: 1500, to: 2000, color: '#FF6B6B' },
143 { from: 2000, to: 2500, color: '#4ECDC4' },
144 { from: 2500, to: 3000, color: '#45B7D1' }
145 ]
146 }}
147 />
148 );
149}
150```
151
152## Common Patterns
153
154### Pattern 1: Hierarchical Data with Drill-Down
155
156```jsx
157<TreeMapComponent
158 enableDrillDown={true}
159 dataSource={data}
160 weightValuePath="Sales"
161>
162 <LevelsDirective>
163 <LevelDirective groupPath="Country" />
164 <LevelDirective groupPath="State" />
165 <LevelDirective groupPath="City" />
166 </LevelsDirective>
167</TreeMapComponent>
168```
169
170**When to use:** Exploring multilevel hierarchies with progressive disclosure through drill-down interaction.
171
172### Pattern 2: Color-Coded Categories
173
174```jsx
175<TreeMapComponent
176 equalColorValuePath="Category"
177 leafItemSettings={{
178 colorMapping: [
179 { value: 'Electronics', color: '#3498db' },
180 { value: 'Furniture', color: '#e74c3c' },
181 { value: 'Clothing', color: '#2ecc71' }
182 ]
183 }}
184/>
185```
186
187**When to use:** Categorizing items with distinct colors for quick visual identification.
188
189### Pattern 3: Value-Range Color Gradient
190
191```jsx
192<TreeMapComponent
193 rangeColorValuePath="Sales"
194 leafItemSettings={{
195 colorMapping: [
196 { from: 0, to: 10000, color: '#90EE90' },
197 { from: 10000, to: 50000, color: '#FFD700' },
198 { from: 50000, to: 100000, color: '#FF6347' }
199 ]
200 }}
201/>
202```
203
204**When to use:** Showing magnitude differences through color intensity for performance metrics, sales, or other continuous values.
205
206## Key Props and Configuration
207
208| Prop | Purpose | Common Values |
209|------|---------|---------------|
210| `dataSource` | Hierarchical or flat data array | Array of objects |
211| `weightValuePath` | Property path for item sizing | e.g., 'Sales', 'Count' |
212| `equalColorValuePath` | Property for categorical coloring | e.g., 'Category', 'Type' |
213| `rangeColorValuePath` | Property for range-based coloring | e.g., 'Sales', 'Value' |
214| `enableDrillDown` | Enable click-to-drill interaction | true/false |
215| `layoutType` | Spatial layout algorithm | 'Squarified', 'Horizontal', 'Vertical', 'SliceAndDice' |
216| `height` | Component height | e.g., '350px', '100%' |
217| `palette` | Array of colors for items | ['#color1', '#color2', ...] |
218
219## Common Use Cases
220
221
222## API Reference
223
224This section summarizes the most commonly used `TreeMap` props, methods, and events. For the complete API with typed models, see the official docs: https://ej2.syncfusion.com/react/documentation/api/treemap/index-default
225
226### Important Properties (selected)
227- `dataSource` (Array|DataManager) — The data source for TreeMap. Can be flat or hierarchical. Default: `null`
228- `weightValuePath` (string) — Path to numeric value used for sizing each item. Default: `null`
229- `colorValuePath` (string) — Field used for continuous color mapping (range palettes).
230- `equalColorValuePath` (string[]) — Field(s) for categorical/equal color mapping.
231- `rangeColorValuePath` (string[]) — Field(s) used for range-based color mapping.
232- `leafItemSettings` (object) — Configuration for leaf items (e.g., `labelPath`, `colorMapping`, `border`, `gap`).
233- `levels` (LevelSettingsModel[]) — Array of level configuration objects to define grouping and appearance per hierarchy level.
234- `layoutType` (string) — Layout algorithm: `Squarified` (default), `SliceAndDiceHorizontal`, `SliceAndDiceVertical`, `SliceAndDiceAuto`, etc.
235- `enableDrillDown` (boolean) — Enable drill-down interaction. Default: `false`
236- `drillDownView` (boolean) — Use drill-down view layout. Default: `false`
237- `enableBreadcrumb` (boolean) — Show breadcrumb when drilling. Default: `false`
238- `breadcrumbConnector` (string) — Separator shown between breadcrumb items.
239- `initialDrillDown` (object) — Configure initial drill-down level/state.
240- `enableHtmlSanitizer` (boolean) — Sanitize HTML in templates/tooltips. Default: `true`
241- `enablePersistence` (boolean) — Persist component state between reloads. Default: `false`
242- `enableRtl` (boolean) — Enable right-to-left rendering. Default: `false`
243- `palette` (string[]) — Array of palette colors used for fills.
244- `highlightSettings` (object) — Highlight configuration and styling.
245- `selectionSettings` (object) — Selection configuration (mode, enable, etc.).
246- `legendSettings` (object) — Legend configuration (position, title, shape, etc.).
247- `titleSettings` (object) — Title and subtitle configuration.
248- `tooltipSettings` (object) — Tooltip templates and behavior.
249- `format` (string) — Formatting string for labels or values.
250- `useGroupingSeparator` (boolean) — Apply grouping separator for numeric values. Default: `true`
251- `description` (string) — Accessibility description for the TreeMap.
252- `margin` (object) — Margin settings for the component (`{ top, right, bottom, left }`).
253- `height` / `width` (string|number) — Size of the component (e.g., `350px` or `100%`).
254- `theme` (string) — Theme name (e.g., `Material`, `Bootstrap`).
255
256### Common Methods
257- `destroy()` — Clean up the TreeMap instance and remove listeners.
258- `export(type, fileName, orientation, allowDownload)` — Export the TreeMap as `PNG|JPEG|SVG|PDF`. Returns a Promise for PDF export flows.
259- `print(id)` — Print TreeMap content by element id, DOM element, or array of ids.
260- `doubleClickOnTreeMap(e)` — Programmatically trigger double-click behavior.
261- `selectItem(levelOrder, isSelected)` — Select or deselect an item by level order array.
262
263### Common Events
264- `load` / `loaded` — Lifecycle events fired before/after component load.
265- `itemRendering` — Fired while items are rendered; use to customize item appearance.
266- `click` / `itemClick` — Fired on item click.
267- `doubleClick` — Fired on item double click.
268- `drillStart` / `drillEnd` — Fired when drill-down starts/ends.
269- `itemHighlight` / `itemSelected` — Events for highlight/selection lifecycle.
270- `legendRendering` / `legendItemRendering` — Events during legend rendering.
271- `tooltipRendering` — Fired when tooltip content is prepared.
272- `resize` — Fired on component resize.
273- `beforePrint` / `print` — Hooks around printing/export.
274
275### Quick Import Example
276
277```jsx
278import { TreeMapComponent, LevelsDirective, LevelDirective, Inject, TreeMapTooltip } from '@syncfusion/ej2-react-treemap';
279
280<TreeMapComponent dataSource={data} weightValuePath="value" enableDrillDown={true}>
281 <LevelsDirective>
282 <LevelDirective groupPath="category" />
283 </LevelsDirective>
284 <Inject services={[TreeMapTooltip]} />
285</TreeMapComponent>
286```
287
2881. **Organization Hierarchies:** Visualize employee counts across departments, regions, and divisions
2892. **File System Browser:** Display disk usage by folders and subfolders with drill-down
2903. **Sales Performance:** Compare regional sales, product categories, and territories
2914. **Website Analytics:** Explore traffic sources, pages, and user segments hierarchically
2925. **Portfolio Allocation:** Visualize asset distribution across categories and subcategories
2936. **Market Share:** Display competitive landscape with company hierarchies
2947. **Budget Analysis:** Allocate and visualize budget across departments and line items
295
296## Next Steps
297
2981. **Start with Getting Started guide** to install and render your first TreeMap
2992. **Choose a data binding pattern** based on your data structure
3003. **Select color mapping strategy** (range, equal, or desaturation)
3014. **Configure layout** and drill-down if exploring hierarchies
3025. **Customize leaf items, labels, and tooltips** for your use case
3036. **Add interactivity** with selection and events
3047. **Ensure accessibility** and internationalization requirements
305
306---
307
308**Ready to implement TreeMap?** Start with [references/getting-started.md](references/getting-started.md) or choose a specific feature guide from the navigation options above.