Closed chervontsev closed 2 years ago
Fixed it : ) https://codesandbox.io/s/github/chervontsev/vue-network-graph-test-v2-fixed/tree/main/?file=/src/App.vue
The problem seems to have been in changing the model. But if you put your edge behaviour logic in the config everything works as expected!
The same solution can be propagated to other config parts if the need arises.
Quite an awesome library : )
Hi @chervontsev, Thank you for your detailed report and sharing a workaround! You have already reached what I consider to be the optimal solution. However, I think that the behavior where changing any property of an edge triggers a recalculation of the force simulation is undesirable, so I have fixed the library. (v0.5.14) In the latest version, the recalculation is not performed only by changing the edge model as in the first code.
Thank you for using v-network-graph! Best Regards,
Thank you : ) I'll definitely check it out!
Hi I'm building a social connections graph where, while hovering on a person, her closest friends (nodes/edges) are also highlighted.
I made a small demo but there's some glitchy behaviour with ForceLayout. https://codesandbox.io/s/github/chervontsev/vue-network-graph-test-v1/tree/main/?file=/src/App.vue
Is there a more optimal way to do this?
Test cases:
Case 1:
Case 2:
Assumptions
While the twitching and spinning version looks nice and smooth, a lot of elements are being recalculated and redrawn at the same time. Displaying 30-50 nodes, cranks up the CPU load drastically.
This effect happens when I mutate the widths that are set in the edge model. Presumably this change triggers the graph rebuild.
For nodes I used a custom template and access them via $ref. This way the data model is not affected and the structure stays in place.
Conclusion
Is there maybe a way to put refs on edges? Or a way to stop/restart forceSimulation outside of ForceLayout?