问题
we are trying to create a visualisation with D3 which represents a stock portfolios assets with relative sized weightings with 3 levels deep nested data. We have used D3 Pack and a zoom function such as this as a template https://bl.ocks.org/mbostock/7607535
The issue we are facing is D3 pack works from the children up the parent chain, and the parents sizes are not relative to each other due to the fact D3 pack tries to pack the children most efficiently as possible and depending on the number and size of the circles in each container they will be more or less efficient by volume (2 circles of equal size is 50% efficient to its parent circle volume, where as 3 circles is approx. 75% efficient). This means the object with 3 circles appears smaller than the object with 2 circles, even both add up to the same weighting, lets say 50,50 and 33,33,33.
Is there a way to make the parents equal by size for such a visualisation? Essentially this would require additional padding on the smaller circles or scale the children of the larger one down to match. Its an interesting problem and I think the reverse of what D3 pack was set out to achieve but a very practical application.
Thanks in advance.
来源:https://stackoverflow.com/questions/50960702/d3-pack-layout-with-comparable-parents