plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.78k stars 1.84k forks source link

Sankey: sort nodes #4373

Open Mahdis-z opened 4 years ago

Mahdis-z commented 4 years ago

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

etpinard commented 4 years ago

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

antoinerg commented 4 years ago

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

1kastner commented 2 years ago

It would be great to have this feature!

hohuyhoangg commented 11 months ago

@archmoj I really need this feature.

adamreeve commented 7 months ago

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.

scodesido-at-proton commented 5 months ago

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...