Skip to content Skip to sidebar Skip to footer

D3 Sunburst Arc Sizes

I am trying to create a D3 sunburst chart based on this example: https://bl.ocks.org/maybelinot/5552606564ef37b5de7e47ed2b7dc099 I'd like the arcs created to close the full circle

Solution 1:

Your problem appears to be that size variables defined for the parent nodes are included when you do root.sum to make values. Essentially the parent value is set not just to be the sum of its children, but you get the parent size added as "free space"

https://github.com/d3/d3-hierarchy/blob/master/README.md#node_sum

"The node.value property of each node is set to the numeric value returned by the specified function plus the combined value of all descendants."

This works as it ignores non-leaf node size values:

  root.sum(function(d) { return !d.children || d.children.length === 0 ? d.size :0; });

https://jsfiddle.net/uz8rz13d/2/

Post a Comment for "D3 Sunburst Arc Sizes"