Overview
TheTreemap class creates a treemap visualization where hierarchical data is displayed using nested rectangles. The size of each rectangle represents its value.
Class Hierarchy
- Series
- Hierarchy
- Treemap
- Hierarchy
Settings
nodePaddingInner
Gap between nodes in pixels.
nodePaddingOuter
Gap between nodes and outer edge of the chart in pixels.When set, this overrides individual edge padding settings.
nodePaddingTop
Gap between nodes and top edge in pixels.Will be ignored if
nodePaddingOuter is set.nodePaddingBottom
Gap between nodes and bottom edge in pixels.Will be ignored if
nodePaddingOuter is set.nodePaddingLeft
Gap between nodes and left edge in pixels.Will be ignored if
nodePaddingOuter is set.nodePaddingRight
Gap between nodes and right edge in pixels.Will be ignored if
nodePaddingOuter is set.layoutAlgorithm
Algorithm to use when laying out node rectangles.
"squarify"- Creates approximately square rectangles (default)"binary"- Uses binary partitioning"slice"- Divides horizontally"dice"- Divides vertically"sliceDice"- Alternates between slice and dice by depth
Inherited Settings
Treemap inherits all settings from Hierarchy, including:sort- How to sort nodes by value (“ascending” | “descending” | “none”)valueField- Field in data holding numeric valuecategoryField- Field in data holding category namechildDataField- Field in data holding array of childrendownDepth- Number of child levels to show when drilling downupDepth- Number of parent levels to show from selected nodeinitialDepth- Number of levels to show on first loadtopDepth- Starting level to show (hides upper levels)singleBranchOnly- Collapse other branches when one expandsanimationDuration- Duration for drill animations in millisecondsanimationEasing- Easing function for animationscolors- ColorSet for auto-assigning node colorspatterns- PatternSet for auto-assigning node patterns
Data Item Properties
Each data item in a Treemap chart has the following properties:children
An array of children data items.
parent
Parent data item.
rectangle
The RoundedRectangle element representing this node.
value
Value of the node as set in data.
sum
Sum of child values.
valuePercentTotal
Percent value of the node, based on total sum of all nodes in upper level.
valuePercent
Percent value of the node, based on the value of its direct parent.Since: 5.2.21
category
Category name of the node.
depth
Node’s depth within the hierarchy (0 for root).
node
Reference to the visual HierarchyNode element.
label
Reference to node’s Label element.
fill
Node’s auto-assigned color.
fillPattern
Node’s auto-assigned pattern.Since: 5.10.0
disabled
Indicates if node is currently disabled (collapsed).
Data Format
Example Data
List Templates
Treemap provides access to these list templates for customization:nodes
List of all node container elements.
rectangles
List of node rectangle elements in the Treemap chart.
labels
List of label elements.
Containers
nodesContainer
Container that holds all node elements.
Methods
selectDataItem()
The data item to select.
getDataItemById()
The ID to search for.
The found data item, or undefined if not found.
enableDataItem()
Target data item to enable.
Maximum depth to enable children to.
Current depth (used internally for recursion).
Animation duration in milliseconds.
disableDataItem()
Target data item to disable.
Animation duration in milliseconds.
addChildData()
Parent data item to add children to.
Array of child data objects.
hoverDataItem()
Target data item.
unhoverDataItem()
Target data item.
Events
dataitemselected
The selected data item.
Private Settings
These are read-only private settings managed internally:scaleX
Current horizontal scale.
scaleY
Current vertical scale.