d3-sankey icon indicating copy to clipboard operation
d3-sankey copied to clipboard

nodePadding as a function?

Open curran opened this issue 6 years ago • 2 comments

It would be great to be able to pass a function into nodePadding, so that different nodes can have different padding.

My particular use case for this is showing hierarchical data, for which the nodes on the top level have a larger font size than the ones in the lower level.

image

Currently with a global nodePadding value, the padding is driven by the larger font size, and leaves unnecessary space between the nodes with the smaller font size.

curran avatar Aug 16 '18 05:08 curran

Related, I just fixed #63 where if the padding was too large resulting, we’d produce negative node heights. If we make the padding variable for each node, the fix for large values will presumably be more complicated. Also, what’s the desired behavior when two adjacent nodes have different padding? Use the maximum of the two similar to CSS margin-collapse?

mbostock avatar Sep 02 '19 00:09 mbostock

+1 on this request. It would be nice to help to nicely vertically align nodes.

ogelin avatar Nov 17 '20 19:11 ogelin