简体   繁体   English

D3强制布局固定位置

[英]D3 Force layout fix positions

I'm using D3's forced layout graph to plot the data. 我正在使用D3的强制布局图来绘制数据。

When I call the update function using setInterval with new data, the force layout graph nodes start from a random position. 当我使用带有新数据的setInterval调用update函数时,强制布局图节点从随机位置开始。 How can I fix this? 我怎样才能解决这个问题?

I read other answers such as using dx dy or alpha(0) , in case of alpha(0) it did not work but dx dy using was successful until the data is changed and then the new node is not in same position as it is supposed to be. 我读了其他答案,例如使用dx dyalpha(0) ,如果使用alpha(0)则不起作用,但成功使用dx dy直到更改数据,然后新节点的位置不正确应该是。

My Current working fiddle: https://jsfiddle.net/mootqvs1/5/ 我当前的工作提琴: https : //jsfiddle.net/mootqvs1/5/

In D3.js version 3 you have a property fixed for the node to stay at the current position. 在D3.js版本3中,您已修复了一个属性,该属性使节点保持在当前位置。 In version 4 this property is replaced with d.fx and d.fy, if they are set the node will stay at that position. 在版本4中,将此属性替换为d.fx和d.fy(如果已设置),则节点将停留在该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM