Angular TreeMap API

The TreeMap is a widget that displays hierarchical data by using nested rectangles.

import { DxTreeMapModule } from "devextreme-angular"
Type: DxTreeMapTypes.default

In the TreeMap widget, hierarchical data is represented by a set of nested rectangles whose sizes are proportional to the visualized values. TreeMap operates with plain and hierarchical data sources. Also, it can visualize a hierarchy reconstructed from a flat data source.

TreeMap provides three layout algorithms out-of-the-box along with the capability to implement your own algorithm. In addition, the widget includes API methods that enable you to implement the drill down feature. Moreover, TreeMap supports all interactive features available in other DevExtreme Data Visualization Widgets: click, hover and selection.

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the TreeMap widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
var fruitsVegetables = [{
    name: 'Fruits',
    items: [
        { name: 'Apples', value: 4 },
        { name: 'Oranges', value: 10 },
        { name: 'Lemons', value: 6 }
    ]
}, {
    name: 'Vegetables',
    items: [
        { name: 'Cucumbers', value: 4 },
        { name: 'Tomatoes', value: 8 },
        { name: 'Turnips', value: 7 }
    ]
}];
$(function() {
    $("#treeMap").dxTreeMap({
        dataSource: fruitsVegetables
    });
});
<div id="treeMap"></div>
Angular
HTML
TypeScript
<dx-tree-map [dataSource]="fruitsVegetables"></dx-tree-map>
export class AppComponent {
    fruitsVegetables = [
        // ...   
    ];
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-tree-map="{
        dataSource: fruitsVegetables
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.fruitsVegetables = [
            // ...   
        ];
    });
Knockout
HTML
JavaScript
<div data-bind="dxTreeMap: {
    dataSource: fruitsVegetables
}"></div>
var viewModel = {
    fruitsVegetables: [
        // ...
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().TreeMap()
    .ID("treeMap")
    .DataSource(FruitsVegetables)
)
@(Html.DevExtreme().TreeMap() _
    .ID("treeMap") _
    .DataSource(FruitsVegetables)
)

View Demo Watch Video

See Also

Configuration

This section describes properties that configure the contents, behavior and appearance of the TreeMap widget.

Name Description
childrenField

Specifies the name of the data source field that provides nested items for a group. Applies to hierarchical data sources only.

colorField

Specifies the name of the data source field that provides colors for tiles.

colorizer

Manages the color settings.

dataSource

Specifies the origin of data for the widget.

disabled

Specifies whether the widget responds to the user interaction.

elementAttr

Specifies the attributes to be attached to the widget's root element.

export

Configures the exporting and printing features.

group

Configures groups.

hoverEnabled

Specifies whether tiles and groups change their style when a user pauses on them.

idField

Specifies the name of the data source field that provides IDs for items. Applies to plain data sources only.

interactWithGroup

Specifies whether the user will interact with a single tile or its group.

labelField

Specifies the name of the data source field that provides texts for tile and group labels.

layoutAlgorithm

Specifies the layout algorithm.

layoutDirection

Specifies the direction in which the items will be laid out.

loadingIndicator

Configures the loading indicator.

maxDepth

Specifies how many hierarchical levels must be visualized.

onClick

A function that is executed when a node is clicked or tapped.

onDisposing

A function that is executed before the widget is disposed of.

onDrawn

A function that is executed when the widget's rendering has finished.

onDrill

A function that is executed when a user drills up or down.

onExported

A function that is executed after the widget is exported.

onExporting

A function that is executed before the widget is exported.

onFileSaving

A function that is executed before a file with exported widget is saved to the user's local storage.

onHoverChanged

A function that is executed after the pointer enters or leaves a node.

onIncidentOccurred

A function that is executed when an error or warning occurs.

onInitialized

A function that is executed only once, after the widget is initialized.

onNodesInitialized

A function that is executed only once, after the nodes are initialized.

onNodesRendering

A function that is executed before the nodes are displayed and each time the collection of active nodes is changed.

onOptionChanged

A function that is executed after a widget option is changed.

onSelectionChanged

A function that is executed when a node is selected or the selection is canceled.

parentField

Specifies the name of the data source field that provides parent IDs for items. Applies to plain data sources only.

pathModified

Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path.

redrawOnResize

Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates.

resolveLabelOverflow

Decides whether those labels that overflow their tile/group should be hidden or truncated with ellipsis.

rtlEnabled

Switches the widget to a right-to-left representation.

selectionMode

Specifies whether a single or multiple nodes can be in the selected state simultaneously.

size

Specifies the widget's size in pixels.

theme

Sets the name of the theme the widget uses.

tile

Configures tiles.

title

Configures the widget's title.

tooltip

Configures tooltips - small pop-up rectangles that display information about a data-visualizing widget element being pressed or hovered over with the mouse pointer.

valueField

Specifies the name of the data source field that provides values for tiles.

Methods

This section describes methods that can be called to manipulate the TreeMap widget.

Name Description
beginUpdate()

Prevents the widget from refreshing until the endUpdate() method is called.

clearSelection()

Deselects all nodes in the widget.

dispose()

Disposes of all the resources allocated to the TreeMap instance.

drillUp()

Drills one level up.

element()

Gets the root widget element.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

exportTo(fileName, format)

Exports the widget.

getCurrentNode()

Gets the current node.

getDataSource()

Gets the DataSource instance.

getInstance(element)

Gets the instance of a widget found using its DOM node.

getRootNode()

Gets the root node.

getSize()

Gets the current widget size.

hideLoadingIndicator()

Hides the loading indicator.

hideTooltip()

Hides the tooltip.

instance()

Gets the widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all widget options.

option(optionName)

Gets the value of a single option.

option(optionName, optionValue)

Updates the value of a single option.

option(options)

Updates the values of several options.

print()

Opens the browser's print window.

render()

Redraws the widget.

resetDrillDown()

Resets the drill down level.

showLoadingIndicator()

Shows the loading indicator.

svg()

Gets the widget's SVG markup.

Events

This section describes events fired by this widget.

Name Description
click

Raised when a node is clicked or tapped.

disposing

Raised before the widget is disposed of.

drawn

Raised when the widget's rendering has finished.

drill

Raised when a user drills up or down.

exported

Raised after the widget is exported.

exporting

Raised before the widget is exported.

fileSaving

Raised before a file with exported widget is saved to the user's local storage.

hoverChanged

Raised after the pointer enters or leaves a node.

incidentOccurred

Raised when an error or warning occurs.

initialized

Raised only once, after the widget is initialized.

nodesInitialized

Raised only once, after the nodes are initialized.

nodesRendering

Raised before the nodes are displayed and each time the collection of active nodes is changed.

optionChanged

Raised after a widget option is changed.

selectionChanged

Raised when a node is selected or the selection is canceled.

See Also

Node

This section describes the Node object, which represents a treemap node.

Node objects are accessible within certain event handlers, for example, onNodesInitialized, onNodesRendering, etc. Also, you can obtain these objects using the getRootNode() and getCurrentNode() methods.