[英]D3 SVG transition issue after deleting few nodes
I am facing a weird issue in this jsfiddle . 我在这个jsfiddle面临着一个奇怪的问题。 If I delete few existing nodes and add new nodes later, the transition of nodes doesn't stay the same.
如果我删除几个现有节点并稍后添加新节点,则节点的转换不会保持不变。
This scenario is working fine : 这种情况很好 :
reset
button reset
按钮 ctee
node which is connected to a few other nodes and drag. ctee
节点并拖动。 ctee
node are also moving along with ctee
. ctee
节点的节点也随着ctee
一起移动。 This scenario is having a problem (only difference is we are going to delete a node first and then click reset
button) : 这种情况有问题 (唯一不同的是我们将首先删除节点,然后单击
reset
按钮):
GW
node and select the option Stop
. GW
节点,然后选择Stop
。 reset
button reset
按钮 ctee
node which is connected to a few other nodes and drag. ctee
节点并拖动。
- check out the following screenshot, the connected nodes to the
ctee
node are not moving along withctee
.查看以下屏幕截图,
ctee
节点的连接节点不与ctee
一起移动。
The issue looks like that when you delete a node, you're creating a new reference to links
that is not in sync with your force layout: 问题看起来就像当您删除节点时,您正在创建对与您的强制布局不同步的
links
的新引用:
links = links.filter...
To fix this, you can simply add: force.links(links);
要解决这个问题,你可以简单地添加:
force.links(links);
to the line after it to update the force layout's reference. 到它之后的行更新力布局的参考。
Updated fiddle: https://jsfiddle.net/r1tcj0mf/16/ 更新小提琴: https : //jsfiddle.net/r1tcj0mf/16/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.