documentationfor yFiles for HTML 2.6

TreeMapLayout

This layout algorithm produces tree map layouts.

Inheritance Hierarchy
TreeMapLayout
Implemented Interfaces

Remarks

Layout Style

Tree maps are suitable to visualize hierarchical data structures. They use nested rectangles to do so, where the size of the rectangles encodes its weight. More generally, the area of a rectangle is proportional to a specific dimension of data associated to it.

Tree maps can, for example, be used to show a file structure on a hard disk, where the dimension of data is the size of the files/folders. There are many other use cases where the tree map can show the distribution of the dimension of data among the entities in a hierarchy.

A tree map with four different sub-groups - node labels define the weight; note that there are no edges in a tree map

Concept

TreeMapLayout offers implementations of the well-known treemapping-algorithms Slice-and-Dice and Squarified. These tiling policies divide a rectangle with a given size into multiple sub-rectangles. Speaking in terms of graphs this means that nodes are placed in a nested fashion such that child nodes are placed inside the parent node.

Importantly, node sizes are changed by this layout algorithm to show the proportional weight of a node in the map. The weight is specified by registering a IDataProvider with key NODE_WEIGHT_DP_KEY with the input graph.

Features

The input can be specified in two ways:

  1. As a hierarchic grouping structure that defines the nesting. Note that for group nodes, the specified insets are considered (see GROUP_NODE_INSETS_DP_KEY). If the graph is a tree graph, then the grouping structure is ignored - see second input variant. To continue using the hierarchy information of the grouping structure on a tree graph, one can temporarily hide the tree edges before running the layout.
  2. As a directed tree graph. The parent-child relation is directly taken from the graph's tree structure. If the graph also contains group nodes, the hierarchy relation induced by them is ignored. If necessary, an undirected tree can be (temporarily) directed prior to the layout run by using directTree. The tree needs to be directed from the root (top-level hierarchy) to the children (lower-level hierarchies). Note that a forest graph is no valid input.

The offered tiling policies produce drawings with a quite different style. SLICE_AND_DICE offers results that have a stable, clear ordering but the rectangles have a high aspect ratio. On the other hand, SQUARIFIED tries to create rectangles close to a given aspect ratio - in consequence, the ordering of neighbor nodes might not be clearly predictable.

Default Values of Properties

minimumNodeSizeYDimensionMinimum width and height are 10.0.
nodeComparerNodeWeightComparerNodes are ordered with respect to their weight (higher weight first).
preferredSizeYDimensionPreferred width and height are 600.
spacing5
tilingPolicySQUARIFIED

Type Details

yfiles module
layout-tree
yfiles-umd modules
layout-orthogonal-compact, layout-orthogonal, layout-tree, layout
Legacy UMD name
yfiles.tree.TreeMapLayout

See Also

If the range of the provided weights is large, i.e., a large difference between the minimum and maximum weight value, then the resulting tree map might become really large, making readability bad. The reason is that the relative weight differences need to be considered while still satisfying the minimum node size for the nodes with low weight. A solution would be to scale/interpolate the weight values before running the layout.
Due to insets specified at parent nodes of different hierarchies and the inter-node padding defined by the spacing, nodes that have the same actual weight can get slightly different sizes - especially if they are on different hierarchy levels. This is necessary to satisfy the specified distances and insets. If exact same sizes throughout hierarchies is a requirement, set the spacing to 0 and do not specify insets for the group nodes that have children (if input is specified as grouping structure).
Edges are generally not routed by this layout algorithm. If there are any, their path will be reset such that they become straight lines. If defining the input as a tree graph, edges can be removed after the layout run to get a clean tree map drawing without any edges across the map. If defining the input via grouping, no edges are necessary whatsoever.
This layout algorithm does not consider NodeHalos assigned to nodes.

Constructors

Properties

Methods

Constants