d3力图:粘性节点 [英] d3 force graph: sticky nodes

查看:105
本文介绍了d3力图:粘性节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在D3中添加一个行为到强制有向图布局,一旦删除,一个拖放的svg节点粘在它的位置,不再改变位置,不管在图形。我已经做了关于这个API的一些阅读,但我不能弄清楚一个方法来让这个API工作。

I would like to add a behavior to a force directed graph layout in D3 in such a way that once dropped, a dragged-and-dropped svg node sticks in its place, no longer changing position no matter what else happens in the graph. I have done some reading about this API but I can't figure out a way to get that one working.

我想解决的问题是允许用户分离一个复杂的力图。

The problem I am trying to solve is allowing a user to "pick apart" a complex force graph.

推荐答案

在mousedown上将节点的固定属性设置为true。

Set the fixed property of the node to true on mousedown.

node.on("mousedown", function(d) { d.fixed = true; });

例如: http://bl.ocks.org/3750558

这篇关于d3力图:粘性节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆