dash14 / v-network-graph

An interactive network graph visualization component for Vue 3
https://dash14.github.io/v-network-graph/
MIT License
504 stars 44 forks source link

Dynamic node list, d3force and stored positions #137

Closed kogratte closed 9 months ago

kogratte commented 10 months ago

Hey :)

First of all, I'm aware of https://dash14.github.io/v-network-graph/examples/layout.html#fix-the-position-of-a-specific-node-in-the-force-layout.

BUT :)

https://www.loom.com/share/507ffbd7c00248e49807eeaf7ab69391

As you can see, the first time, positioning is indeed what was already stored. If I hide / show nodes again, position is wrong. If I reload the page, and show ancestors nodes, then they're well placed.

I cannot understand why they are well placed at round 1, but not after.

dash14 commented 9 months ago

Hi @kogratte, Sorry for the late reply, and thanks for reporting the Issue!

First, the library's behavior is that when a node is deleted from the graph, the position of the deleted node is also deleted from the layouts. If layouts is specified as a bi-directional binding, the result of deletion is applied to the parent component's layouts. When re-adding a deleted node to the graph, the position before the deletion should be added to the layouts as well.

If layouts is specified as a unidirectional binding (not bidirectional), the deletion of a node position will not be applied to the parent component. The parent component will still have the position it had before the deletion in the parent component's managed layouts. In this situation, when a deleted node is re-added from the graph, the position specified by the parent component should be used, but there was a bug that prevented this from being used.

We have fixed it and released v0.9.14.

kogratte commented 9 months ago

Don't worry for the late reply.

Thanks for the update, it'll fix some strange behaviors I have not been able to deal with.

Le mer. 20 déc. 2023 à 15:53, dash14.ack @.***> a écrit :

Hi @kogratte https://github.com/kogratte, Sorry for the late reply, and thanks for reporting the Issue!

First, the library's behavior is that when a node is deleted from the graph, the position of the deleted node is also deleted from the layouts. If layouts is specified as a bi-directional binding, the result of deletion is applied to the parent component's layouts. When re-adding a deleted node to the graph, the position before the deletion should be added to the layouts as well.

If layouts is specified as a unidirectional binding (not bidirectional), the deletion of a node position will not be applied to the parent component. The parent component will still have the position it had before the deletion in the parent component's managed layouts. In this situation, when a deleted node is re-added from the graph, the position specified by the parent component should be used, but there was a bug that prevented this from being used.

We have fixed it and released v0.9.14 https://github.com/dash14/v-network-graph/releases/tag/v0.9.14.

— Reply to this email directly, view it on GitHub https://github.com/dash14/v-network-graph/issues/137#issuecomment-1864609676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAORHVNEECEC2AV57JQZS53YKL3VLAVCNFSM6AAAAABAKAJBZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRUGYYDSNRXGY . You are receiving this because you were mentioned.Message ID: @.***>

ThuanLCSE commented 9 months ago

Happy new year @dash14 ! Thank you and your team for the new version. 👍

dash14 commented 9 months ago

Thank you for your reaction, @kogratte, @ThuanLCSE ! I will close this issue. If you continue to have problems or questions, please reply to this Issue or submit a new issue.