documentationfor yFiles for HTML 3.0.0.3

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 with 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 strategies 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 via layout data property nodeWeights.

Features

The input can be specified in two ways:

  1. As a hierarchical grouping structure that defines the nesting. Note that for group nodes, the specified padding are considered (see GROUP_NODE_PADDING_DATA_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 makeTreeDirected. 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 strategies 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

minimumNodeSizeSizeMinimum width and height are 10.0.
preferredSizeSizePreferred width and height are 600.
spacing5
tilingStrategySQUARIFIED

Type Details

yFiles module
algorithms
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 minimumNodeSize for the nodes with low weight. A solution would be to scale/interpolate the weight values before running the layout.
Due to padding 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 padding. If exact same sizes throughout hierarchies is a requirement, set the spacing to 0 and do not specify padding 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 paths 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 margins assigned to nodes.

Constructors

Properties

Methods

Constants