plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.39k stars 2.56k forks source link

loop to direct links (and reverse) transformation after node drag-and-drop in Sankey diagram #4493

Open Atrema6 opened 10 months ago

Atrema6 commented 10 months ago

Links mode does not change from direct to loop or reverse after node drag-and-drop. The same thing happens if initial nodes position is changed with XY coordinates. It appears that the mode is fixed after initial alignment and that it cannot be changed despite changes in XY coordinates causing some loops to be broken and others to be created. HTML and Javascript environment.

Plotly Sankey

https://plotly.com/python/sankey-diagram/

Expected behaviour: Links mode (loop to direct and reverse) is redefined after (or during) each change of node position (drag-and-drop or setting XY coordinates)

PS: this tool is amazing, I discovered it after using Google's оne, and its flexibility is incredible

Coding-with-Adam commented 10 months ago

hi @Atrema6 Thank you for opening this issue. Can you please share more about the bug. Is it present in this gif that I made?

sankey

Atrema6 commented 10 months ago

Hi @Coding-with-Adam Yes, it would be expected if some links were switched to loop mode in this case. But the reverse case is much more annoying - when you move a node with an initial loop link to a position where the loop should disappear, instead of switching to a direct link, you get a weird broken loop edge (see picture above). You can check it with the loop chart by the link above.

archmoj commented 10 months ago

@Atrema6 I was not able to replicate the problem. Please provide an animated gif or video file. Thank you!

Atrema6 commented 10 months ago

@archmoj Анимация

alexcjohnson commented 10 months ago

Thanks @Atrema6 - that makes the issue quite clear, and I can reproduce it in the sankey-circular mock. When you drag C to the right of D, the link from D->C (the one that exits the right side of D and enters the left side of C) should change from a loop to an S-curve, not the crazy self-crossing jagged loop. And the link from C->D should become a loop, rather than an S-curve that subtly overlays both the source and target nodes, giving the impression of a flow in the wrong direction.

The solution must be, as your initial comment implies, that the test we do during the initial draw to determine which links are forward and which loop backward needs to be repeated while dragging.

Atrema6 commented 10 months ago

@alexcjohnson thanks for contributing! Yes, exactly, but not only when dragging, but also after XY coordinates are changed, since even when XY coordinates are set during initialisation, they are applied after test is complete. The initial test is applied to default nodes before XY coordinates are applied.