使用forceX / Y时无法更改链接强度

时间:2018-09-10 12:33:15

标签: javascript d3.js

我有这个codepen:https://codepen.io/anon/pen/gdXprR?editors=1010

我可以通过按UI中的按钮来更改链接的强度,这将更改以下内容:

force.force('link').strength(+linkStrength);
force.alpha(1).restart();

现在,当我按UI中的按钮时,对网络没有任何影响。但是,当我更改此力时:

.force('x', d3v5.forceX(width / 2))
.force('y', d3v5.forceY(height / 2));

对此:

.force('center', d3v5.forceCenter(width / 2, height / 2))

这是密码笔:https://codepen.io/anon/pen/QVQwRp?editors=1010

降低强度是有效的。

我的问题是为什么?以及如何使用原始设置,即设置forceXforceY并能够更改链接强度,以便节点在屏幕上分布得更多?

谢谢

0 个答案:

没有答案