Skip to content

Node Padding

nodePadding resolves per node, so a single wide gap can separate groups within a column while every other gap stays at the default (see Usage for how the requested pixel value relates to what actually renders). Adjacent gaps collapse like CSS margins — max(prevNode.after, nextNode.before) — rather than summing, so only one side needs to grow. The same grouping could come from a function instead of a keyed object, if which nodes belong together has to be worked out from the data rather than known up front.

Deprecated. nodePaddingMode keeps working until 1.0, where it is removed without a replacement, and it has an effect only with nodeAlign: 'auto' (the default). nodeAlign 'start' and 'end' give exactly the requested gaps, except where a flow that skips columns is held level. What follows, the measured gaps included, holds for nodeAlign: 'auto'.

By default (nodePaddingMode: 'auto'), each column is packed with the requested gaps and then every node is moved as close as it can get to where its flows meet the nodes at the other end, without changing the order and without bringing two nodes closer than the gap. A column whose nodes are all pulled the same way keeps the requested gaps, but where two neighbours are pulled apart the gap between them grows. Below, four sources feed two middle nodes: the source column keeps the gap you ask for, while the gap between Thermal and Renewables grows to about 1.6 times nodePadding (31.5 px for a requested 20 px, measured on the 598 px by 420 px chart below), and so does the first gap of the last column (24.4 px). nodePaddingMode: 'even' moves a column as one block instead, so every gap is exactly the requested one, but nodes are no longer aligned with their flows, so those flows bend more to reach their target. Drag nodePadding to see both modes respond to the same requested gap:

auto and even only diverge when moving a node towards its flows opens a gap wider than the requested one. The first example on this page has a single node in its middle column, so there is no gap to widen there, and auto and even would draw that column the same way.