mirror of
https://github.com/cjo4m06/mcp-shrimp-task-manager.git
synced 2025-07-26 07:52:25 +08:00
feat: 增加基于节点度数的垂直分布力,避免过于分散或聚集
This commit is contained in:
parent
0f22b41682
commit
2b2d002f31
@ -910,7 +910,17 @@ function renderDependencyGraph() {
|
||||
// 其他节点在中间
|
||||
return width * 0.5;
|
||||
}
|
||||
}).strength(0.2)) // 调整力的强度,可以根据需要调整
|
||||
}).strength(0.2))
|
||||
// 新增:基于节点度数的垂直分布力
|
||||
.force("y", d3.forceY().y(height / 2).strength(d => {
|
||||
// 计算节点的总度数(入度+出度)
|
||||
const inDegree = links.filter(l => (l.target.id || l.target) === d.id).length;
|
||||
const outDegree = links.filter(l => (l.source.id || l.source) === d.id).length;
|
||||
const totalDegree = inDegree + outDegree;
|
||||
|
||||
// 度数越大,力越大(基础力0.05,每个连接增加0.03,最大0.3)
|
||||
return Math.min(0.05 + totalDegree * 0.03, 0.3);
|
||||
}))
|
||||
.on("tick", ticked);
|
||||
|
||||
// 添加用於存放連結和節點的組
|
||||
|
Loading…
x
Reference in New Issue
Block a user