plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Sankey: sort nodes

Open Mahdis-z opened this issue 5 years ago • 5 comments

Would be very useful to add a feature to enable users to sort nodes based on their desired output.

Mahdis-z avatar Nov 20 '19 19:11 Mahdis-z

@antoinerg can you confirm that the current sankey implementation does not allow sorting nodes?

etpinard avatar Nov 26 '19 19:11 etpinard

@etpinard I confirm we don't currently allow sorting nodes. However, it seems like underlying engines support it:

antoinerg avatar Nov 26 '19 20:11 antoinerg

It would be great to have this feature!

1kastner avatar Sep 27 '21 20:09 1kastner

@archmoj I really need this feature.

hohuyhoangg avatar Aug 31 '23 08:08 hohuyhoangg

I'm also interested in this feature, and had a look into implementing this. The main challenge is that the plotly fork of d3-sankey (https://github.com/plotly/d3-sankey) is quite old and doesn't include the nodeSort feature, so either that feature needs to be ported to the plotly fork, or recent changes from upstream need to be merged into the fork. plotly/d3-sankey-circular would also need updating.

Then you can simply call sankey.nodeSort(null) so that the order of nodes is based on the order in the input array rather than letting the layout reorder them.

adamreeve avatar Jan 07 '24 20:01 adamreeve

Pinging here, this feature would be really useful for reproducibility. I understand we can specify x/y coordinates, but if I have to do a nontrivial layout like that, I may as well paint traces myself without using Plotly. It is a bit weird that this is supported by the underlying d3 but plotly cannot expose. This kind of issue has been open for years now...

scodesido-at-proton avatar Mar 07 '24 16:03 scodesido-at-proton