Sizing Issue with Nested Treemap

I was trying to implement a nested treemap, such that a Group can have both Groups & Nodes inside them. For this, I had used the Treemap Extension (Tree Map) as the base.

I created a template for the Node, and two templates for the Group (one for expanded, other for the collapsed state).

Collapsed State for Group
image

Expanded State for Group

The issue is that, the sum of the totals(sizes) of nodes and sub-groups should be equal to the total(size) of the group. Since the expanded state of the group also have a header, there is an issue where the nodes & the subgroups are overflowing the placeholder.
I suspect, it is because the group is trying to retain its total(size), and the nodes and subgroups are also trying to retain their totals(sizes). Hence, there is a sizing constraint because of the header (since total(size) of the group does not equate the sum of totals(sizes) of the nodes & subgroups.)

In my initial exploration, it seems the size of the placeholder is also calculated automatically, hence we cannot set it manually. I was wondering if there is a way to set the size of the placeholder, such that the child nodes & subgroups somehow adjust their sizes relative to the available space in the placeholder, and don’t overflow?

OR

Is it possible that the header of the expanded group somehow is not inclusive of the size of the group.

For reference: The initial draft highlighting the issue where the children are overflowing the parent group

I think you’ll need to modify the TreeMapLayout so that the area of each group is the sum of its members plus the area needed for the header. So that it lays out the members in a reduced area of the whole group.

You’ll need to decide what to do when the total area expected to be taken by a group is smaller than the area of the header. Or even when the header area is a substantial percentage of the total.