This layout algorithm produces tree map layouts.
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.
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:
- 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.
- 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
minimumNodeSize | Size
| Minimum width and height are 10.0 . |
preferredSize | Size
| Preferred width and height are 600 . |
spacing | 5 | |
tilingStrategy | SQUARIFIED
|
Type Details
- yFiles module
- algorithms
0
and do not specify padding for the group nodes that have children (if input is specified as grouping structure).Constructors
Initializes a new instance of the TreeMapLayout class with default settings.
Parameters
A map of options to pass to the method.
- tilingStrategy - TilingStrategy
- The TilingStrategy that defines how the input is divided into sub-rectangles. This option sets the tilingStrategy property on the created object.
- minimumNodeSize - Size
- The minimum size (height and width) a node in the tree map must have. This option sets the minimumNodeSize property on the created object.
- preferredSize - Size
- The desired dimension of the root rectangle into which all nodes are placed. This option sets the preferredSize property on the created object.
- aspectRatio - number
- The target aspect ratio of the SQUARIFIED tiling strategy. This option sets the aspectRatio property on the created object.
- spacing - number
- The spacing between nodes of the same hierarchy. This option sets the spacing property on the created object.
Properties
Gets or sets the target aspect ratio of the SQUARIFIED tiling strategy.
Remarks
The aspect ratio must be greater than or equal to 1
. A ratio of 1
means that the node rectangles should ideally be squares. The orientation of the rectangles does not matter. For example, a ratio of 2
means that rectangles with an aspect ratio of 1:2
or also 2:1
are desired.
This setting affects the ratio of a single node rectangle. To create a tree map with a certain overall aspect ratio, the preferredSize can be specified accordingly.
Default Value
1
.The target is to draw square nodes.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is smaller than
1
See Also
Gets or sets the minimum size (height and width) a node in the tree map must have.
Remarks
Default Value
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the width or height of the given size is smaller than
5
Gets or sets the desired dimension of the root rectangle into which all nodes are placed.
Remarks
Default Value
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if width/height value of the given size is less than or equal to
zero
Gets or sets the spacing between nodes of the same hierarchy.
Remarks
Default Value
5
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given spacing is negative
Sample Graphs
Gets or sets the TilingStrategy that defines how the input is divided into sub-rectangles.
Methods
Arranges the given input graph as a tree map.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Implements
createLayoutData
(graph: LayoutGraph) : TreeMapLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the TreeMapLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪TreeMapLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given TreeMapLayout.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the TreeMapLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪TreeMapLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given TreeMapLayout.
LayoutExecutor
type is available at runtime.Constants
A data key for specifying the weight of the nodes.
Remarks
The weight of a node defines the area assigned to the node inside the available parent area with respect to the other child nodes. Child nodes with the same weight get the same area, they do not necessarily get equal width and height values.
All leaf nodes (nodes without further children, including empty group nodes) must have a weight greater than 0
. Non-leaf nodes do not need to have a weight. They will basically get the sum of the weight of their children. If they have a weight on their own, some free space is generated inside the representative rectangle (i.e. the parent node is larger than the combined children).