Skip to content Skip to sidebar Skip to footer

D3 Sankey Diagram - Enforce Node Position

Using the D3 Sankey plugin, I'm updating a Sankey diagram with new values (on changing the data, passing new values for the nodes and links -- keeping all of them consistent). Is

Solution 1:

No, there isn't. If you want to dive into the layout, here's where you want to look:

function computeNodeDepths(iterations) {
 var nodesByBreadth = d3.nest()
    .key(function(d) { return d.x; })
    .sortKeys(d3.ascending)
    .entries(nodes)
    .map(function(d) { return d.values; });

initializeNodeDepth();
...

Notice that sortKeys points at d3.ascending. You'd want this to point to some kind of hard-wired value, which you'd need to compute either in the first iteration or in your data preparation. It will still get adjusted when the collision detection function is run, so you might see your nodes pushed out of position but this will give you the best chance to maintain some control.


Post a Comment for "D3 Sankey Diagram - Enforce Node Position"