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.

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.

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.