Implementing Syncfusion Angular TreeMap
The TreeMap component visualizes hierarchical or grouped data as nested rectangles. Each rectangle represents a data item, and its size is determined by a numeric field mapped through weightValuePath. TreeMaps are useful for displaying structures such as product categories, regional breakdowns, market segments, or any grouped dataset where relative magnitude matters.
When to Use This Skill
- Visualizing hierarchical data: Display grouped or multi-level data such as regions, departments, or product categories
- Multi-level data visualization: Show parent-child relationships using
levels and groupPath
- Creating drill-down interfaces: Enable interactive navigation through hierarchy levels
- Color-coding data: Use range, equal, desaturation, palette, or direct color binding
- Adding interactive features: Implement selection, highlight, click, double-click, and right-click interactions
- Customizing appearance: Modify layout, colors, borders, labels, headers, legends, and templates
- Displaying supplementary information: Add labels, tooltips, legends, and formatted values
- Exporting visualizations: Print or export as PNG, JPEG, SVG, or PDF
- International support: Enable RTL, locale-specific number formatting, and culture-aware display
- Accessibility: Improve screen reader support, ARIA naming, contrast, and focus behavior
Documentation and Navigation Guide
Choose your reference based on what you need to accomplish:
API Reference
📄 Read: references/api-reference.md
Getting Started
📄 Read: references/getting-started.md
- Installation and npm package setup
- Importing
TreeMapModule
- Creating your first TreeMap component
- Theme and style configuration
- Basic component with simple data
Data Binding
📄 Read: references/data-binding.md
- Binding flat collections
- Grouping data with
levels
- Mapping data source properties to TreeMap fields
- Configuring
weightValuePath for item sizing
- Dynamic data updates and state-driven binding
Color Mapping
📄 Read: references/color-mapping.md
- Range color mapping for numeric values
- Equal color mapping for category-based colors
- Desaturation color mapping with opacity
- Palette-based coloring
- Direct color binding with
colorValuePath
- Gradient colors with
leafItemSettings.colorMapping
Drilldown and Navigation
📄 Read: references/drilldown-and-navigation.md
- Enabling drilldown functionality
- Parent-child navigation with
levels
drillDownView behavior
- Breadcrumb navigation
- Drill events (
drillStart, drillEnd)
- Resetting to root through application state when needed
Levels and Layout
📄 Read: references/levels-and-layout.md
- Configuring multiple hierarchy levels
groupPath and grouped rendering
- Layout types (
Squarified, SliceAndDiceVertical, SliceAndDiceHorizontal, SliceAndDiceAuto)
- Group spacing and leaf gaps
- Header formatting and styling
- Header templates and header sizing
Labels, Tooltips, and Legend
📄 Read: references/labels-tooltips-legend.md
- Data label configuration and formatting
- Label templates and template positioning
- Handling label intersections and overflow
- Tooltip visibility and formatting
- Custom tooltip templates
- Legend display and configuration
- Coordinating legend with color mapping, selection, and highlight
Selection and Interactivity
📄 Read: references/selection-interactivity.md
- Enabling selection and highlight
- Customizing selection colors and borders
- Legend-based selection and hover interaction
- Click, item-selected, double-click, and right-click events
- Programmatic selection with
selectItem(...)
- Managing single-item or multi-item workflows in application state
Print, Export, and Accessibility
📄 Read: references/print-export-accessibility.md
- Print functionality
- Image export (PNG, JPEG, SVG)
- PDF export with orientation options
- Base64 export handling
- WCAG accessibility support
- Screen reader support and ARIA labels
- Contrast and focus considerations
Internationalization
📄 Read: references/internationalization.md
- Right-to-left (RTL) rendering
- Locale configuration and number formatting
- Globalization for labels and tooltips
- Render direction configuration
- Multi-language data binding
- Cultural customization with
setCulture() and setCurrencyCode()
Quick Start
import { Component, signal } from '@angular/core';
import { TreeMapModule } from '@syncfusion/ej2-angular-treemap';
@Component({
selector: 'app-treemap',
standalone: true,
imports: [TreeMapModule],
template: `
<ejs-treemap
id="treemap-container"
[dataSource]="data()"
weightValuePath="Size"
[levels]="levels"
[leafItemSettings]="leafItemSettings">
</ejs-treemap>
`,
styles: [`
#treemap-container {
display: block;
width: 100%;
height: 500px;
}
`]
})
export class TreeMapComponent {
public data = signal([
{ Category: 'Electronics', Item: 'Laptops', Size: 150 },
{ Category: 'Electronics', Item: 'Phones', Size: 200 },
{ Category: 'Furniture', Item: 'Chairs', Size: 100 },
{ Category: 'Furniture', Item: 'Tables', Size: 120 }
]);
public levels = [
{ groupPath: 'Category' }
];
public leafItemSettings = {
labelPath: 'Item',
gap: 4,
border: { color: '#ffffff', width: 1 }
};
}
Common Patterns
Pattern 1: Basic Hierarchical Visualization
Display grouped hierarchical data using levels and groupPath.
public levels = [
{ groupPath: 'Region', headerFormat: '${Region}' },
{ groupPath: 'Country', headerFormat: '${Country}' }
];
public leafItemSettings = {
labelPath: 'Country'
};
Pattern 2: Color-Mapped Values
Use range color mapping through rangeColorValuePath and leafItemSettings.colorMapping.
<ejs-treemap
[dataSource]="data()"
weightValuePath="Value"
rangeColorValuePath="Value"
[leafItemSettings]="leafItemSettings">
</ejs-treemap>
public leafItemSettings = {
labelPath: 'Name',
colorMapping: [
{ from: 0, to: 50, color: '#3498db' },
{ from: 50, to: 100, color: '#e74c3c' }
]
};
Pattern 3: Interactive Drilldown
Enable drilldown with breadcrumb navigation for exploring grouped levels.
<ejs-treemap
[dataSource]="data()"
weightValuePath="Value"
[enableDrillDown]="true"
[enableBreadcrumb]="true"
breadcrumbConnector=" / "
[levels]="levels"
[leafItemSettings]="leafItemSettings">
</ejs-treemap>
Key Props and Configuration
| Property |
Type |
Purpose |
dataSource |
object[] |
Data collection for TreeMap items |
weightValuePath |
string |
Numeric field used to size each item |
leafItemSettings |
object |
Leaf item configuration such as labels, borders, templates, and color mapping |
levels |
object[] |
Hierarchy configuration using groupPath and header settings |
layoutType |
'Squarified' | 'SliceAndDiceVertical' | 'SliceAndDiceHorizontal' | 'SliceAndDiceAuto' |
Rectangle arrangement algorithm |
colorValuePath |
string |
Data field used for direct item color assignment |
equalColorValuePath |
string |
Data field used for category-based color mapping |
rangeColorValuePath |
string |
Data field used for numeric range color mapping |
enableDrillDown |
boolean |
Enables drilldown navigation through grouped levels |
enableBreadcrumb |
boolean |
Displays breadcrumb navigation during drilldown |
legendSettings |
object |
Legend display and styling configuration |
tooltipSettings |
object |
Tooltip visibility, formatting, and template configuration |
selectionSettings |
object |
Selection appearance and behavior configuration |
highlightSettings |
object |
Hover highlight appearance configuration |
enableRtl |
boolean |
Enables right-to-left rendering |
locale |
string |
Overrides the component culture |
format |
string |
Applies numeric formatting such as n2, c, or p |
useGroupingSeparator |
boolean |
Enables culture-aware number grouping separators |
allowPrint |
boolean |
Enables print support |
allowImageExport |
boolean |
Enables image export support |
allowPdfExport |
boolean |
Enables PDF export support |
description |
string |
Adds descriptive accessibility text for the component |
tabIndex |
number |
Controls focus order for the TreeMap container |
Implementation Notes
- Prefer
TreeMapModule for focused standalone Angular components.
- Use
TreeMapLegendService, TreeMapTooltipService, TreeMapSelectionService, TreeMapHighlightService, PrintService, ImageExportService, and PdfExportService only when the corresponding features are enabled.
- For color mapping, configure
leafItemSettings.colorMapping and pair it with equalColorValuePath or rangeColorValuePath when needed.
- For programmatic selection, use
selectItem(levelOrder, isSelected?) rather than unsupported helper methods.
- For accessibility, rely on TreeMap’s built-in ARIA support, meaningful titles, labels, legends, descriptions, and strong color contrast.
- For keyboard and advanced interaction workflows, provide surrounding Angular controls where needed rather than assuming extra undocumented TreeMap keyboard APIs.
1---2name: syncfusion-angular-treemap3description: Create and customize Syncfusion Angular TreeMap components for hierarchical data visualization. Use this skill when you need to implement a TreeMap, visualize hierarchical data structures, configure multi-level layouts, apply color mapping, enable drilldown navigation, add labels and tooltips, configure legends, handle selection and highlight, export to images or PDF, print, or customize internationalization and accessibility. Covers installation, data binding, layout types, levels, color mapping, labels, tooltips, legends, drilldown, interactivity, print/export, RTL, locale formatting, and accessibility.4---56# Implementing Syncfusion Angular TreeMap78The TreeMap component visualizes hierarchical or grouped data as nested rectangles. Each rectangle represents a data item, and its size is determined by a numeric field mapped through `weightValuePath`. TreeMaps are useful for displaying structures such as product categories, regional breakdowns, market segments, or any grouped dataset where relative magnitude matters.910## When to Use This Skill1112- **Visualizing hierarchical data**: Display grouped or multi-level data such as regions, departments, or product categories13- **Multi-level data visualization**: Show parent-child relationships using `levels` and `groupPath`14- **Creating drill-down interfaces**: Enable interactive navigation through hierarchy levels15- **Color-coding data**: Use range, equal, desaturation, palette, or direct color binding16- **Adding interactive features**: Implement selection, highlight, click, double-click, and right-click interactions17- **Customizing appearance**: Modify layout, colors, borders, labels, headers, legends, and templates18- **Displaying supplementary information**: Add labels, tooltips, legends, and formatted values19- **Exporting visualizations**: Print or export as PNG, JPEG, SVG, or PDF20- **International support**: Enable RTL, locale-specific number formatting, and culture-aware display21- **Accessibility**: Improve screen reader support, ARIA naming, contrast, and focus behavior2223## Documentation and Navigation Guide2425Choose your reference based on what you need to accomplish:2627### API Reference28📄 **Read:** `references/api-reference.md`2930### Getting Started31📄 **Read:** `references/getting-started.md`32- Installation and npm package setup33- Importing `TreeMapModule`34- Creating your first TreeMap component35- Theme and style configuration36- Basic component with simple data3738### Data Binding39📄 **Read:** `references/data-binding.md`40- Binding flat collections41- Grouping data with `levels`42- Mapping data source properties to TreeMap fields43- Configuring `weightValuePath` for item sizing44- Dynamic data updates and state-driven binding4546### Color Mapping47📄 **Read:** `references/color-mapping.md`48- Range color mapping for numeric values49- Equal color mapping for category-based colors50- Desaturation color mapping with opacity51- Palette-based coloring52- Direct color binding with `colorValuePath`53- Gradient colors with `leafItemSettings.colorMapping`5455### Drilldown and Navigation56📄 **Read:** `references/drilldown-and-navigation.md`57- Enabling drilldown functionality58- Parent-child navigation with `levels`59- `drillDownView` behavior60- Breadcrumb navigation61- Drill events (`drillStart`, `drillEnd`)62- Resetting to root through application state when needed6364### Levels and Layout65📄 **Read:** `references/levels-and-layout.md`66- Configuring multiple hierarchy levels67- `groupPath` and grouped rendering68- Layout types (`Squarified`, `SliceAndDiceVertical`, `SliceAndDiceHorizontal`, `SliceAndDiceAuto`)69- Group spacing and leaf gaps70- Header formatting and styling71- Header templates and header sizing7273### Labels, Tooltips, and Legend74📄 **Read:** `references/labels-tooltips-legend.md`75- Data label configuration and formatting76- Label templates and template positioning77- Handling label intersections and overflow78- Tooltip visibility and formatting79- Custom tooltip templates80- Legend display and configuration81- Coordinating legend with color mapping, selection, and highlight8283### Selection and Interactivity84📄 **Read:** `references/selection-interactivity.md`85- Enabling selection and highlight86- Customizing selection colors and borders87- Legend-based selection and hover interaction88- Click, item-selected, double-click, and right-click events89- Programmatic selection with `selectItem(...)`90- Managing single-item or multi-item workflows in application state9192### Print, Export, and Accessibility93📄 **Read:** `references/print-export-accessibility.md`94- Print functionality95- Image export (PNG, JPEG, SVG)96- PDF export with orientation options97- Base64 export handling98- WCAG accessibility support99- Screen reader support and ARIA labels100- Contrast and focus considerations101102### Internationalization103📄 **Read:** `references/internationalization.md`104- Right-to-left (RTL) rendering105- Locale configuration and number formatting106- Globalization for labels and tooltips107- Render direction configuration108- Multi-language data binding109- Cultural customization with `setCulture()` and `setCurrencyCode()`110111## Quick Start112113```typescript114import { Component, signal } from '@angular/core';115import { TreeMapModule } from '@syncfusion/ej2-angular-treemap';116117@Component({118 selector: 'app-treemap',119 standalone: true,120 imports: [TreeMapModule],121 template: `122 <ejs-treemap123 id="treemap-container"124 [dataSource]="data()"125 weightValuePath="Size"126 [levels]="levels"127 [leafItemSettings]="leafItemSettings">128 </ejs-treemap>129 `,130 styles: [`131 #treemap-container {132 display: block;133 width: 100%;134 height: 500px;135 }136 `]137})138export class TreeMapComponent {139 public data = signal([140 { Category: 'Electronics', Item: 'Laptops', Size: 150 },141 { Category: 'Electronics', Item: 'Phones', Size: 200 },142 { Category: 'Furniture', Item: 'Chairs', Size: 100 },143 { Category: 'Furniture', Item: 'Tables', Size: 120 }144 ]);145146 public levels = [147 { groupPath: 'Category' }148 ];149150 public leafItemSettings = {151 labelPath: 'Item',152 gap: 4,153 border: { color: '#ffffff', width: 1 }154 };155}156```157158## Common Patterns159160### Pattern 1: Basic Hierarchical Visualization161162Display grouped hierarchical data using `levels` and `groupPath`.163164```typescript165public levels = [166 { groupPath: 'Region', headerFormat: '${Region}' },167 { groupPath: 'Country', headerFormat: '${Country}' }168];169170public leafItemSettings = {171 labelPath: 'Country'172};173```174175### Pattern 2: Color-Mapped Values176177Use range color mapping through `rangeColorValuePath` and `leafItemSettings.colorMapping`.178179```typescript180<ejs-treemap181 [dataSource]="data()"182 weightValuePath="Value"183 rangeColorValuePath="Value"184 [leafItemSettings]="leafItemSettings">185</ejs-treemap>186```187188```typescript189public leafItemSettings = {190 labelPath: 'Name',191 colorMapping: [192 { from: 0, to: 50, color: '#3498db' },193 { from: 50, to: 100, color: '#e74c3c' }194 ]195};196```197198### Pattern 3: Interactive Drilldown199200Enable drilldown with breadcrumb navigation for exploring grouped levels.201202```typescript203<ejs-treemap204 [dataSource]="data()"205 weightValuePath="Value"206 [enableDrillDown]="true"207 [enableBreadcrumb]="true"208 breadcrumbConnector=" / "209 [levels]="levels"210 [leafItemSettings]="leafItemSettings">211</ejs-treemap>212```213214## Key Props and Configuration215216| Property | Type | Purpose |217|----------|------|---------|218| `dataSource` | `object[]` | Data collection for TreeMap items |219| `weightValuePath` | `string` | Numeric field used to size each item |220| `leafItemSettings` | `object` | Leaf item configuration such as labels, borders, templates, and color mapping |221| `levels` | `object[]` | Hierarchy configuration using `groupPath` and header settings |222| `layoutType` | `'Squarified' \| 'SliceAndDiceVertical' \| 'SliceAndDiceHorizontal' \| 'SliceAndDiceAuto'` | Rectangle arrangement algorithm |223| `colorValuePath` | `string` | Data field used for direct item color assignment |224| `equalColorValuePath` | `string` | Data field used for category-based color mapping |225| `rangeColorValuePath` | `string` | Data field used for numeric range color mapping |226| `enableDrillDown` | `boolean` | Enables drilldown navigation through grouped levels |227| `enableBreadcrumb` | `boolean` | Displays breadcrumb navigation during drilldown |228| `legendSettings` | `object` | Legend display and styling configuration |229| `tooltipSettings` | `object` | Tooltip visibility, formatting, and template configuration |230| `selectionSettings` | `object` | Selection appearance and behavior configuration |231| `highlightSettings` | `object` | Hover highlight appearance configuration |232| `enableRtl` | `boolean` | Enables right-to-left rendering |233| `locale` | `string` | Overrides the component culture |234| `format` | `string` | Applies numeric formatting such as `n2`, `c`, or `p` |235| `useGroupingSeparator` | `boolean` | Enables culture-aware number grouping separators |236| `allowPrint` | `boolean` | Enables print support |237| `allowImageExport` | `boolean` | Enables image export support |238| `allowPdfExport` | `boolean` | Enables PDF export support |239| `description` | `string` | Adds descriptive accessibility text for the component |240| `tabIndex` | `number` | Controls focus order for the TreeMap container |241242## Implementation Notes243244- Prefer `TreeMapModule` for focused standalone Angular components.245- Use `TreeMapLegendService`, `TreeMapTooltipService`, `TreeMapSelectionService`, `TreeMapHighlightService`, `PrintService`, `ImageExportService`, and `PdfExportService` only when the corresponding features are enabled.246- For color mapping, configure `leafItemSettings.colorMapping` and pair it with `equalColorValuePath` or `rangeColorValuePath` when needed.247- For programmatic selection, use `selectItem(levelOrder, isSelected?)` rather than unsupported helper methods.248- For accessibility, rely on TreeMap’s built-in ARIA support, meaningful titles, labels, legends, descriptions, and strong color contrast.249- For keyboard and advanced interaction workflows, provide surrounding Angular controls where needed rather than assuming extra undocumented TreeMap keyboard APIs.