d3 force graph: sticky nodes

被刻印的时光 ゝ 提交于 2019-12-10 13:13:17

问题


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.


回答1:


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

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

For example: http://bl.ocks.org/3750558



来源:https://stackoverflow.com/questions/12496851/d3-force-graph-sticky-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!