You can create a hierarchical treemap by providing an array of keys to the groups option within a dataset. Each string in the array represents a level of nesting in the hierarchy. For example, groups: ['region', 'division'] will first group data by region, and then sub-group those regions by division.
When using groups, the tree property should contain the hierarchical data structure, and the key property specifies which numeric value determines the size of the rectangles at each level.
const config = {
type: 'treemap',
data: {
datasets: [{
tree: Data.statsByState,
key: 'area',
groups: ['region', 'division'],
spacing: 1,
borderWidth: 0.5,
borderColor: 'rgba(200,200,200,1)',
backgroundColor: 'rgba(220,230,220,0.3)',
hoverBackgroundColor: 'rgba(220,230,220,0.5)',
}]
},
options: {
// ...
}
};