block by danharr af796d91926d254dfe99

Position nodes horizontally in Sankey diagram

Full Screen

Solution is not finished and needs more understanding. Trying to position the nodes horizontally in a sankey diagram according to data. Hard coding these values for now at the bottom:

graph.links[3].source.x = 200; graph.links[7].source.x = 100; graph.links[7].target.x = 500; graph.links[5].target.x = 800;

then updating the links and rects. Oddly, the rects know to position themselves automatically. I would have thought I’d need to have changed the data first:

graph.nodes[5].dx = 800 etc //but this isn’t necessary it seems, not sure yet why

I've disabled drag functionality too as the labels get all jumbled up otherwise

added back drag functionality, had to comment out this line which was affecting node order //.on("dragstart", function() { this.parentNode.appendChild(this); })

index.html

data.csv

sankey.js