plotly.js
plotly.js copied to clipboard
Sankey: sort nodes
Would be very useful to add a feature to enable users to sort nodes based on their desired output.
@antoinerg can you confirm that the current sankey implementation does not allow sorting nodes?
@etpinard I confirm we don't currently allow sorting nodes. However, it seems like underlying engines support it:
-
d3-sankey
supports it -
d3-sankey-circular
offers some kind of sorting
It would be great to have this feature!
@archmoj I really need this feature.
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.
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...