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

[Bug] Sankey diagram - loop to direct links (and reverse) transformation after node drag-and-drop

Open Atrema6 opened this issue 2 years ago • 6 comments

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

Atrema6 avatar Jan 23 '24 05:01 Atrema6

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

Coding-with-Adam avatar Jan 23 '24 19:01 Coding-with-Adam

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.

Atrema6 avatar Jan 24 '24 02:01 Atrema6

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

archmoj avatar Jan 26 '24 15:01 archmoj

@archmoj Анимация

Atrema6 avatar Jan 26 '24 21:01 Atrema6

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.

alexcjohnson avatar Feb 01 '24 06:02 alexcjohnson

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

Atrema6 avatar Feb 01 '24 06:02 Atrema6