TreeMap

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

Included in: dx.viz.js, dx.viz-web.js, dx.all.js
Module: viz/tree_map
Export: default
TreeMap interactive configuration
Copy Code
Copy to Codepen
$("#treemap").dxTreeMap({
});

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.

You can create the TreeMap widget using one of the following approaches.

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)
)

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

View Demo Watch Video

See Also

Configuration

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

Methods

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

Events

This section describes events fired by this widget.

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.