Configuration

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

childrenField

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

Type: String
Default Value: 'items'

In hierarchical data sources, objects normally have at least one nested array of objects. To specify the field providing this array, assign its name to the childrenField option. Such hierarchical objects will be visualized by groups of tiles.

See Also
  • dataSource - specifies the origin of data for the widget.
  • valueField - specifies the data source field that provides values for tiles.
  • labelField - specifies the data source field that provides texts for tile and group labels.

colorField

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

Type: String
Default Value: 'color'

There are several approaches to colorizing tiles.

  • Colorizing each tile uniquely into the color specified directly in the data object.
  • Colorizing tiles using the colorizer.
  • Specifying a single color for all tiles using the tile | color option.

You can use the first approach only if objects of your data source contain a field providing colors. If so, assign the name of this field to the colorField option. The colors must have one of the following formats:

This approach has the highest priority among the others. To get familiar with the other two approaches, see the colorizer and tile | color option descriptions.

Show Example:
AngularJS
Knockout
jQuery

In this example, each data source object has three color fields. You can change the applied color field using the select box under the treemap.


                                    

                                    

                                    

In this example, each data source object has three color fields. You can change the applied color field using the select box under the treemap.


                                    

                                    

                                    

In this example, each data source object has three color fields. You can change the applied color field using the select box under the treemap.


                                    

                                    

                                    

colorizer

Manages the color settings.

Type: Object

There are several approaches to colorizing tiles.

  • Colorizing each tile uniquely into the color specified directly in the data object.
  • Colorizing tiles using the colorizer.
  • Specifying a single color for all tiles using the tile | color option.

If for some reason you cannot use the first approach, colorize tiles using the colorizer object. It offers three colorization algorithms: "discrete", "gradient" and "range". For more information on how to use each algorithm, refer to the type option description.

To find out how else you can colorize tiles, see the colorField and tile | color option descriptions.

View Demo Watch Video

dataSource

Specifies the origin of data for the widget.

Cannot be used in themes.

This option accepts one of the following.

  • Array of objects
    A simple JavaScript array containing a collection of plain objects.

  • URL
    A URL to JSON data or to a service returning data in JSON format.

  • DataSource or its configuration object
    A DataSource is an object that provides a handy API for data processing. A DataSource is a stateful object, which means that it saves data processing settings and applies them each time data is loaded. All underlying data access logic of a DataSource is isolated in a Store. A Store provides an API for reading and modifying data. Unlike the DataSource, a Store is a stateless object.

Basically, all data providers contain data objects. Objects that have a plain structure are visualized by tiles. For example, the following data source produces four individual tiles.

JavaScript
var treeMapOptions = {
    // ...
    dataSource: [
        { name: 'Apples', value: 10 },
        { name: 'Oranges', value: 13 },
        { name: 'Cucumbers', value: 4 },
        { name: 'Tomatoes', value: 8 }
    ]    
};

Hierarchically-structured objects are visualized by groups of tiles. For example, the following data source arranges the tiles from the previous code snippet in two groups: "Fruits" and "Vegetables".

JavaScript
var treeMapOptions = {
    // ...
    dataSource: [{
        name: 'Fruits',
        items: [
            { name: 'Apples', value: 10 },
            { name: 'Oranges', value: 13 }
        ]
    }, {
        name: 'Vegetables',
        items: [
            { name: 'Cucumbers', value: 4 },
            { name: 'Tomatoes', value: 8 }
        ]
    }] 
};

After providing data, bind it to the widget using the valueField, labelField and childrenField options.

In certain cases, you may have a plain data source that implies a hierarchical structure. For example, the following code declares such a data source. Nevertheless, it will be visualized in the same manner as the data source from the code snippet above.

JavaScript
var treeMapOptions = {
    // ...
    dataSource: [
        { id: 1, name: 'Fruits'},
        { parent: 1, name: 'Apples', value: 10 },
        { parent: 1, name: 'Oranges', value: 13 },

        { id: 2, name: 'Vegetables' },
        { parent: 2, name: 'Cucumbers', value: 4 },
        { parent: 2, name: 'Tomatoes', value: 8 }
    ],
    idField: 'id',
    parentField: 'parent'
};

Note that in this data source, objects that have children have the "id" field whose value is unique. Their children have the "parent" field pointing at the parent's ID. The "id" and "parent" fields can have other names, but in any case, they must be assigned to the idField and parentField options. Otherwise, you will get four individual tiles (as in the first code snippet) instead of two groups by two tiles. To specify the fields that provide values and labels, use the valueField and labelField options as well.

The examples above show how to provide data using an array of objects. If you are looking for a more powerful and versatile data solution, consider using the DataSource object. To learn how to implement a DataSource that serves your needs best, refer to the Data Source Examples article.

View hierarchical Data Structure Demo View Flat Data Structure Demo

Watch Video

See Also

elementAttr

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

Type: Object
Default Value: {}

When you configure this option in an ASP.NET MVC Control, pass a dictionary as shown in the following code.

Razor C#
Razor VB
@(Html.DevExtreme()
    // other widget options
    // ...
    .ElementAttr(new Dictionary<string, object>() {
        { "id", "elementId" },
        { "class", "class-name" },
        // ...
    })
)
@(Html.DevExtreme().WidgetName() _
    .ElementAttr(New Dictionary(Of String, Object) From {
        { "id", "elementId" },
        { "class", "class-name" }
    })
)

export

Configures the exporting and printing features.

Type: Object

These features allow a user to export your widget into a document or print it. When exporting is enabled, the "Exporting/Printing" button appears in the widget. A click on it invokes a drop-down menu that lists exporting and printing commands. The following formats are supported for exporting into: PNG, PDF, JPEG, SVG and GIF.

NOTE
IE9 and Safari on Mac OS do not implement an API for saving files. Therefore, exporting in these browsers requires setting up a server-side proxy. For details, refer to the proxyUrl option description.
See Also

Watch Video

group

Configures groups.

Type: Object

A group is an element that collects several tiles in it. In terms of data, it is a node that has children in the current context. Groups appear only if the data source implies a hierarchical structure.

The following list provides an overview of group features that you can configure using the group object.

  • Labels
    Each group is identified by a label. Its appearance can be changed using the fields of the label object. If the group's width is too small, the label will be hidden.
  • Headers' Height
    Group headers contain labels. To specify the height of the group headers, use the headerHeight option.
  • Color
    There are several approaches to colorizing the group headers. Refer to the color option description to find information about all of them.
  • Hover and Selection Styles
    A group can be in the hover or selected state. In these states, its style changes to the one specified by the hoverStyle or selectionStyle object respectively. A group can also enter the hover or selected state when a nested tile enters it. To enable this feature, assign true to the interactWithGroup option of the root configuration object.
  • Border's Appearance
    Specify the fields of the border object to configure group borders.

An object assigned to the group field configures all groups in the widget. To customize a specific group, pass a similar object to the customize(options) method of the node represented by the group.

hoverEnabled

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

Type: Boolean
Default Value: undefined
NOTE
When the user pauses on a group, not only the group changes its style, but also tiles that belong to that group. However, the isHovered() method, which checks the tiles' state, will return false although visually they have entered the hover state.
See Also
Show Example:
AngularJS
Knockout
jQuery

In this example, click the check box under the treemap to change the value of the hoverEnabled option.


                                    

                                    

In this example, click the check box under the treemap to change the value of the hoverEnabled option.


                                    

                                    

In this example, click the check box under the treemap to change the value of the hoverEnabled option.


                                    

                                    

idField

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

Type: String
Default Value: undefined

In certain cases, you may have a plain data source that implies a hierarchical structure. For example, the following code declares a data source that, despite being plain, can be rearranged into a hierarchy of two groups with two items in each.

JavaScript
var treeMapOptions = {
    // ...
    dataSource: [
        // Group 1
        { id: 1, name: 'Fruits'},
        { parent: 1, name: 'Apples', value: 10 },
        { parent: 1, name: 'Oranges', value: 13 },

        // Group 2
        { id: 2, name: 'Vegetables' },
        { parent: 2, name: 'Cucumbers', value: 4 },
        { parent: 2, name: 'Tomatoes', value: 8 }
    ]
};

Note that in this data source, objects that have children have the "id" field whose value is unique. Their children have the "parent" field pointing at the parent's ID. The "id" and "parent" fields can have other names, but in any case, they must be assigned to the idField and parentField options.

JavaScript
var treeMapOptions = {
    // ...
    idField: 'id',
    parentField: 'parent'
};

interactWithGroup

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

Type: Boolean
Default Value: false

By default, the click, hoverChanged and selectionChanged events are fired for the tile that has been clicked, paused on or selected. If you need these events to be passed on to the parent group of the tile, set the interactWithGroup option to true. This setting impacts appearance as well. For example, when the user pauses on a tile, the whole group to which the tile belongs will apply the hover style.

Show Example:
AngularJS
Knockout
jQuery

In this example, click the check box under the treemap to change the value of the interactWithGroup option. To spot the difference, point the mouse cursor to a tile.


                                    

                                    

In this example, click the check box under the treemap to change the value of the interactWithGroup option. To spot the difference, point the mouse cursor to a tile.


                                    

                                    

In this example, click the check box under the treemap to change the value of the interactWithGroup option. To spot the difference, point the mouse cursor to a tile.


                                    

                                    

labelField

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

Type: String
Default Value: 'name'

Each tile or group of tiles is accompanied by a text label. Usually, a label displays the name of the tile or the group. However, you can put any desired text into it. For this purpose, call the label(label) method of the node whose label must be changed. You can call this method, for example, when all nodes are initialized or when they are being rendered.

If you need to change the appearance of all labels, use the tile | label and group | label objects. To change the appearance of a particular label, use the customize(options) function of the node to which the label belongs.

See Also
  • dataSource - specifies the origin of data for the widget.
  • valueField - specifies the data source field that provides values for tiles.
  • childrenField - specifies the data source field that provides nested items for a group.

layoutAlgorithm

Specifies the layout algorithm.

Type: String| function
Function parameters:
Data for implementing a custom layout algorithm.
Object structure:
rect: Array
The rectangle available for subdivision.
Contains the X and Y coordinates of two diagonally-opposite points in the following format: [x1, y1, x2, y2].
sum: Number
The sum total value of all nodes on the current level.
items: Array
A set of items to distribute. Each object in this array contains the value and rect fields.
By default, rect is undefined. It must be assigned an array of the following format: [x1, y1, x2, y2], where (x1, y1) and (x2, y2) are coordinates of two diagonally-opposite points defining a rectangle.
Default Value: 'squarified'
Accepted Values: 'squarified' | 'strip' | 'sliceanddice'

Layout algorithms determine the position and size of tiles and groups. Therefore, the chosen algorithm plays the definitive role in the resulting look of the widget. TreeMap provides the following algorithms out of the box.

  • Squarified
    This algorithm lays the items out so that the aspect ratio will be closer to 1. In other words, this algorithm tries to make items as square as possible.

    For more information about this algorithm, refer to the Squarified Treemaps paper.

  • Strip
    This algorithm is a modification of the "Squarified" algorithm. At the beginning, the algorithm has an available area divided into several strips and a set of items to distribute between the strips. Throughout the layout process, a current strip is maintained. For each item to be arranged, the algorithm checks whether or not adding the item to the current strip improves the average aspect ratios of the rectangles in the current strip. If so, the item is added to the current strip. Otherwise, it is added to the next strip.

    The direction of the strips depends on the size of the available area. If the width is greater than the height, the strips are lined up horizontally. If vice versa, vertically.

    For more information on this algorithm, see the Ordered and Quantum Treemaps: Making Effective Use of 2D Space to Display Hierarchies paper.

  • Slice and Dice
    This algorithm uses parallel lines to divide an available area into rectangles representing items. In case of a hierarchical structure, each rectangle representing an item is divided once more into smaller rectangles representing its children, and so on.

    To learn more about this algorithm, refer to the Tree Visualization with Tree-Maps: a 2D Space-Filling Approach paper.

DevExpress DevExtreme HTML5 TreeMap Squarified SliceAndDice Strip

If none of the predefined algorithms satisfy your needs, implement your own algorithm. For this purpose, assign a function to the layoutAlgorithm option. Basically, this function should calculate the coordinates of two diagonally-opposite points defining a rectangle and assign them to the needed item. To access a set of items to distribute, use the items field of the function's parameter. All available fields of the parameter are listed in the header of this description.

JavaScript
var treeMapOptions = {
    // ...
    layoutAlgorithm: function (e) {
        // ...
        e.items.forEach(function(item) {
            // ...
            // Calculating the rectangle for the current item here
            // ...
            item.rect = rectPoints;
        });
    }
};

In addition, you can change the layout direction. For this purpose, use the layoutDirection option.

When using the widget as an ASP.NET MVC Control, you can specify this option using the TreeMapLayoutAlgorithm enum. This enum accepts the following values: Squarified, Strip and SliceAndDice.

View Demo

Show Example:
AngularJS
Knockout
jQuery

In this example, you can change the applied layout algorithm using the select box under the treemap. Moreover, this example shows how to implement a custom layout algorithm (see the customAlgorithm function in the js tab).


                                    

                                    

                                    

In this example, you can change the applied layout algorithm using the select box under the treemap. Moreover, this example shows how to implement a custom layout algorithm (see the customAlgorithm function in the js tab).


                                    

                                    

                                    

In this example, you can change the applied layout algorithm using the select box under the treemap. Moreover, this example shows how to implement a custom layout algorithm (see the customAlgorithm function in the js tab).


                                    

                                    

                                    

layoutDirection

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

Type: String
Default Value: 'leftTopRightBottom'
Accepted Values: 'leftTopRightBottom' | 'leftBottomRightTop' | 'rightTopLeftBottom' | 'rightBottomLeftTop'

The value of this option determines the start and end point of the layout. See the image below to spot the difference between the available layout directions.

DevExpress DevExtreme HTML5 TreeMap LayoutDirection

NOTE
If you use a custom layout algorithm, this option will be ignored.

When using the widget as an ASP.NET MVC Control, you can specify this option using the TreeMapLayoutDirection enum. This enum accepts the following values: LeftTopRightBottom, LeftBottomRightTop, RightTopLeftBottom and RightBottomLeftTop.

Show Example:
AngularJS
Knockout
jQuery

In this example, you can change the applied layout direction using the select box under the treemap.


                                    

                                    

                                    

In this example, you can change the applied layout direction using the select box under the treemap.


                                    

                                    

                                    

In this example, you can change the applied layout direction using the select box under the treemap.


                                    

                                    

                                    

loadingIndicator

Configures the loading indicator.

Type: Object

When the widget visualizes local data, loading is instant. But when the widget is bound to a remote data source, loading may takes a considerable amount of time. To keep the viewer's attention, the widget can display a loading indicator.

DevExtreme HTML5 Charts LoadingIndicator

To activate the loading indicator, assign true to the loadingIndicator | show option. Once data is loaded, the loading indicator will be hidden automatically.

See Also

maxDepth

Specifies how many hierarchical levels must be visualized.

Type: Number
Default Value: undefined

If you have a structure with deep nesting level, displaying all levels at once produces visual clutter. To reduce it, specify the number of levels that can be visualized at a time using the maxDepth property.

DevExpress DevExtreme HTML5 TreeMap

When you set this option, data that occupies the lowest levels may become unavailable to the user. For such cases, implement the drill down feature.

Show Example:
AngularJS
Knockout
jQuery

In this example, the data source has three nesting levels. You can select the maximum level to display using the number box under the treemap.


                                    

                                    

                                    

In this example, the data source has three nesting levels. You can select the maximum level to display using the number box under the treemap.


                                    

                                    

                                    

In this example, the data source has three nesting levels. You can select the maximum level to display using the number box under the treemap.


                                    

                                    

                                    

onClick

A handler for the click event.

Type: function |String
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
jQueryEvent: jQuery.Event
The jQuery event.
The clicked node.
Cannot be used in themes.

When implementing a handling function, use the object passed to it as the parameter. Among the fields of this object, you can find the clicked node. For example, the following function uses the node's select(state) and isSelected() methods to select/deselect the node on a click.

JavaScript
var treeMapOptions = {
    // ...
    onClick: function (e) {
        e.node.select(!e.node.isSelected());
    }
};

To identify whether the clicked node is a tile or a group of tiles, use the isLeaf() method. To learn about other available members of a node, refer to the description of the Node object.

Alternatively, you can navigate to a specific URL when the click event fires. For this purpose, assign this URL to the onClick option.

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
model: Object
The model data. Available only if you use Knockout.
Default Value: null

onDrawn

A handler for the drawn event.

Type: function(e)
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
Cannot be used in themes.

Assign a callback function to this option if you need to perform specific actions when the widget has finished drawing itself. When implementing this function, you can access the drawn widget using the function's parameter.

onDrill

A handler for the drill event.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
The current node.
Cannot be used in themes.

When implementing a handling function, use the object passed to it as the parameter. Among the fields of this object, you can find the currently displayed node. To learn about node's members that you can use, refer to the description of the Node object.

The onDrill event handler can be used to enable/disable other widgets bound to TreeMap. For example, consider that you have a Button. A click on it drills the TreeMap widget one level up from the current node. But when the root node becomes the current, there is nowhere to drill up. In that case, disable the button in the onDrill event handler.

JavaScript
var treeMapOptions = {
    // ...
    onDrill: function (e) {
        if (!e.node.getParent()) // checks whether the node has a parent; if it doesn't, it is the root node
            buttonInstance.option('disabled', true);
        else
            buttonInstance.option('disabled', false);
    };
};

Although not provided out-of-the-box, the drill down capability is easy to implement using the API methods. Learn how to do this from the drillDown() method description.

View Demo Watch Video

onExported

A handler for the exported event.

Type: function(e)
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
model: Object
Data that is available for binding against the element. Available only in the Knockout approach.
Default Value: null

To perform a custom action after data from the widget is exported, assign a function to this option. For example, this function can notify the user that the exporting has been completed. Within this function, you can use the object passed to it as the parameter.

See Also
  • export - configures client-side export and printing.
  • onExporting - allows you to request exporting details and prevent exporting.
  • onFileSaving - allows you to access exported data and/or prevent it from being saved into a file on the user's local storage.

onExporting

A handler for the exporting event.

Type: function(e)
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
model: Object
Data that is available for binding against the element. Available only in Knockout and AngularJS approaches.
fileName: String
The name of the file to which the widget is about to be exported.
cancel: Boolean
Assign true to this field if you need to prevent exporting.
Default Value: null

To perform a custom action before data from the widget is exported, assign a function to this option. Within this function, you can use the object passed to it as the parameter. For example, using the cancel field of this object, you can cancel exporting.

See Also
  • export - configures client-side export and printing.
  • onExported - allows you to notify an end user when exporting is completed.
  • onFileSaving - allows you to access exported data and/or prevent it from being saved into a file on the user's local storage.

onFileSaving

A handler for the fileSaving event.

Type: function(e)
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
fileName: String
The name of the file to be saved.
format: String
The format of the file to be saved.
Possible Values: 'PNG' | 'PDF' | 'JPEG' | 'SVG' | 'GIF'
data: BLOB
Exported data as a BLOB.
cancel: Boolean
Assign true to this field if you need to prevent the file from being saved.
Default Value: null

To perform a custom action before a file with exported data is saved on the user's local storage, assign a function to this option. Within this function, you can use the object passed to it as the parameter. For example, using the cancel field of this object, you can cancel file saving.

See Also
  • export - configures client-side export and printing.
  • onExporting - allows you to request exporting details and prevent exporting.
  • onExported - allows you to notify an end user when exporting is completed.

onHoverChanged

A handler for the hoverChanged event.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
The node whose hover state has been changed.
Cannot be used in themes.

When implementing a handling function, use the object passed to it as its parameter. Among the fields of this object, you can find the node whose hover state has been changed.

To identify whether the node was hovered over or hovered out, call its isHovered() method. To identify whether the node is a single tile or a group of tiles, call its isLeaf() method. Other accessible fields and methods of a node are described in the Node section.

onIncidentOccurred

A handler for the incidentOccurred event.

Type: function(e)
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
target: Object
Information about the occurred incident.

When an error or warning appears, the widget notifies you by passing a message to the browser console. This message contains the ID of the incident, a brief description, and a link to the Errors and Warnings section where further information about this incident can be found. However, you can handle errors and warnings in the way that you require. To do this, implement a callback function performing the required actions and assign it to the onIncidentOccurred option. Within this function, you can use information about the incident that occurred. This information can be accessed from the target field of the object passed to the callback function as a parameter. This information includes the following.

  • id
    Contains the ID of the incident. The full list of IDs can be found in the Errors and Warnings section.
  • type
    Contains the type of the incident. This field equals 'error' for errors or 'warning' for warnings.
  • args
    Contains the argument of the incident's message. The content of this field varies greatly, depending on the incident. For example, it may contain the name of the data source field that was not specified correctly, or the name of the option that was not set properly.
  • text
    Contains the text passed to the browser console. This text includes the content of the args field, if there are any.
  • widget
    Contains the name of the widget that produced the error or warning.
  • version
    Contains the currently used version of the ChartJS library.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
Default Value: null

You cannot access elements in the widget because this handler is executed before they are ready. Use the onContentReady handler instead.

onNodesInitialized

A handler for the nodesInitialized event.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
The root node.
Cannot be used in themes.

Use this handler to perform certain operations on the node structure. It will be called once - at the beginning of the widget's lifetime.

Within the handler, you can use the object passed to it as the parameter. Among the fields of this object, you can find the root node. Using the getAllNodes(), getAllChildren() and getChild(index) methods of this node, you can access any other node in the widget. To learn about other available members of any node including the root node, refer to the description of the Node object.

onNodesRendering

A handler for the nodesRendering event.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
In most cases, the root node. When drilling down, the node of the highest displayed level.
Cannot be used in themes.

Use this handler to customize nodes before they will be displayed. This handler will be called each time the collection of active nodes is changed.

Within the handler, you can use the object passed to it as the parameter. Among the fields of this object, you can find the currently displayed node. Using the getAllNodes(), getAllChildren(), getChild(index) and getParent() of this node, you can access any other node in the widget. To learn about other available members of any node, refer to the description of the Node object.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
name: String
A short name of the option whose value has been changed.
fullName: String
A full name of the option whose value has been changed; contains a full hierarchy of the option.
value: any
A new value for the option.
element: jQuery
The widget's container.
model: Object
The model data. Available only if you use Knockout.
Default Value: null

onSelectionChanged

A handler for the selectionChanged event.

Type: function
Function parameters:
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
The node whose selection state has been changed.
Cannot be used in themes.

When implementing a handling function, use the object passed to it as its parameter. Among the fields of this object, you can find the node whose selection state has been changed.

To identify whether the node was selected or deselected, call its isSelected() method. To identify whether the node is a single tile or a group of tiles, call its isLeaf() method. Other accessible fields and methods of a node are described in the Node section.

parentField

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

Type: String
Default Value: undefined

In certain cases, you may have a plain data source that implies a hierarchical structure. For example, the following code declares a data source that, despite being plain, can be rearranged into a hierarchy of two groups with two items in each.

JavaScript
var treeMapOptions = {
    // ...
    dataSource: [
        // Group 1
        { id: 1, name: 'Fruits'},
        { parent: 1, name: 'Apples', value: 10 },
        { parent: 1, name: 'Oranges', value: 13 },

        // Group 2
        { id: 2, name: 'Vegetables' },
        { parent: 2, name: 'Cucumbers', value: 4 },
        { parent: 2, name: 'Tomatoes', value: 8 }
    ]
};

Note that in this data source, objects that have children have the "id" field whose value is unique. Their children have the "parent" field pointing at the parent's ID. The "id" and "parent" fields can have other names, but in any case they must be assigned to the idField and parentField options.

JavaScript
var treeMapOptions = {
    // ...
    idField: 'id',
    parentField: 'parent'
};

pathModified

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

Type: Boolean
Default Value: false
Cannot be used in themes.

If you place the widget on a page that uses a tag modifying the path (<base>, <iframe>, etc.), some of the widget elements may get mixed up or disappear. To solve this problem, set the pathModified option to true.

See Also

redrawOnResize

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

Type: Boolean
Default Value: true
Cannot be used in themes.

When this option is set to true, the widget will be redrawn automatically in case the size of its parent window changes.

NOTE
To redraw the widget after the size of its container has changed, call the render() method of the widget instance.

resolveLabelOverflow

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

Type: String
Default Value: 'hide'
Accepted Values: 'hide' | 'ellipsis'

When using the widget as an ASP.NET MVC Control, you can specify this option using the TreeMapResolveLabelOverflow enum. This enum accepts the following values: Hide and Ellipsis.

View Demo

rtlEnabled

Specifies whether or not the widget supports right-to-left representation.

Type: Boolean
Default Value: false
Cannot be used in themes.

The most common scenario is switching all the widgets to a right-to-left reading order. In this instance, set the DevExpress.rtlEnabled field to true. If you need to switch the reading order in a particular widget, use the rtlEnabled configuration option of this widget.

selectionMode

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

Type: String
Default Value: undefined
Accepted Values: 'single' | 'multiple' | 'none'

In a single mode, only one node can be in the selected state at one moment. When the user selects another node, the formerly selected node becomes unselected. In a multiple mode, any number of nodes can be in the selected state.

To implement selection, assign the following or similar callback function to the onClick option.

JavaScript
var treeMapOptions = {
    // ...
    onClick: function (e) {
        e.node.select(!e.node.isSelected());
    }    
};

When entering the selected state, a tile or a group of tiles changes its appearance. You can configure it using the group | selectionStyle and tile | selectionStyle objects.

To control the selection feature in code, use the isSelected, select(state) and clearSelection() methods. In addition, you can perform certain actions when a node enters/leaves the selected state. For this purpose, implement the onSelectionChanged event handler.

When using the widget as an ASP.NET MVC Control, specify this option using the SelectionMode enum. This enum accepts the following values: None, Single and Multiple.

Show Example:
AngularJS
Knockout
jQuery

In this example, you can select a tile or a group by clicking it. To change the selection mode, use the select box under the treemap.


                                    

                                    

                                    

In this example, you can select a tile or a group by clicking it. To change the selection mode, use the select box under the treemap.


                                    

                                    

                                    

In this example, you can select a tile or a group by clicking it. To change the selection mode, use the select box under the treemap.


                                    

                                    

                                    

size

Specifies the size of the widget in pixels.

Type: Object
Default Value: undefined

By default, the widget occupies the entire area of the parent container. If you need to set a particular size for the widget, different from the container's size, assign a height and width in pixels to height and width properties of the size object.

Using the size object, you can hide the widget. For this purpose, simply assign 0 to both the height and width of the widget.

theme

Sets the name of the theme to be used in the widget.

Type: String
Default Value: 'generic.light'
Accepted Values: 'generic.light' | 'generic.dark' | 'generic.contrast' | 'android5.light' | 'ios7.default' | 'win10.black' | 'win10.white'

Use this property to set a predefined or custom theme. The options defining chart appearance will be set to the values that are set in the specified theme. You can override some of these values within the chart's configuration object.

NOTE
The following themes were deprecated or renamed: 'desktop', 'desktop-dark', 'android', 'android-holo-light', 'ios', 'win8', 'win8-white', 'win8.white', 'win8.black'. In new applications, use themes listed in the accepted values.

When using the widget as an ASP.NET MVC Control, specify this option using the VizTheme enum. This enum accepts the following values: GenericLight, GenericDark, GenericContrast, Android5Light, IOS7Default, Win10Black and Win10White.

tile

Configures tiles.

Type: Object

A tile is a rectangle representing a node that has no children in the current context. Several tiles can be collected into a group if the data source implies a hierarchical structure.

The following list provides an overview of tiles' features that you can configure using the tile object.

  • Labels
    Each tile is identified by a label. Its appearance can be changed using the fields of the label object. If the tile's area is too small, the label will be hidden.
  • Color
    There are several approaches to colorizing the tiles. Refer to the color option description to find information about all of them.
  • Hover and Selection Styles
    A tile can be in the hover or selected state. In these states, its style changes to the one specified by the hoverStyle or selectionStyle object respectively. Along with the tile, its parent group can enter the hover or selected state. To enable this feature, assign true to the interactWithGroup option of the root configuration object.
  • Border's Appearance
    Specify the fields of the border object to configure the tile borders.

An object assigned to the tile field configures all tiles in the widget. To customize a specific tile, pass a similar object to the customize(options) method of the node represented by the tile.

title

Specifies the widget title.

Type: Object|String

Use this property to set the text to be displayed as the widget title. If you need to specify the title's position in the widget, assign an object to the title property with the required fields specified. In this instance, set the title's text using the text property.

The widget can display additional text in the subtitle. It is placed under the title. Use properties of the subtitle object to assign a text to the subtitle and change its font.

tooltip

Configures tooltips.

Type: Object

A tooltip is a miniature rectangle displaying the widget data. A tooltip appears when the end-user hovers the cursor over a widget element. You can enable/disable tooltips, change their appearance and format their text using fields of the tooltip configuration object.

valueField

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

Type: String
Default Value: 'value'
See Also
  • dataSource - specifies the origin of data for the widget.
  • childrenField - specifies the data source field that provides nested items for a group.
  • labelField - specifies the data source field that provides texts for tile and group labels.