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:
parent
573e4533c5
commit
1f6f79c8aa
1 changed files with 3 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue