Add gravitational forces to node simulation in GraphPanel.vue

- Introduced x and y forces to attract independent nodes towards the center, enhancing the overall layout and clustering of nodes in the graph visualization.
- Improved the simulation dynamics for a more cohesive visual representation of the graph.
This commit is contained in:
666ghj 2025-12-11 13:40:01 +08:00
parent 573e4533c5
commit 1f6f79c8aa

View file

@ -440,6 +440,9 @@ const renderGraph = () => {
.force('charge', d3.forceManyBody().strength(-400))
.force('center', d3.forceCenter(width / 2, height / 2))
.force('collide', d3.forceCollide(50))
//
.force('x', d3.forceX(width / 2).strength(0.04))
.force('y', d3.forceY(height / 2).strength(0.04))
currentSimulation = simulation