D3力有向图与拖放支持使选定的节点位置固定时下降 [英] D3 force directed graph with drag and drop support to make selected node position fixed when dropped

查看:220
本文介绍了D3力有向图与拖放支持使选定的节点位置固定时下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关强制直接图的示例,请参见此处: http://bl.ocks.org/950642

Example on a force direct graph can be found here: http://bl.ocks.org/950642

如何轻松添加对拖放的支持?
它应该将节点设置为固定的当前位置,它放在哪里。
重要的是剩下的节点仍然使用'强制引导模式'自动在图中定位节点的其余部分。

How can I easily add support for drag and drop? It should set the node to fixed with current location of where it dropped it. It is important that rest of the nodes still uses the 'force directed mode' to position rest of the nodes in the graph automatically

https://github.com/mbostock/d3/wiki/Force-Layout

我玩过一些没有成功,想知道是否有人能够给我一个快速示例如何添加如上所述的支持。

I've played around a bit without success, and wondering if anyone is able to give me a quick example on how to add such support as explained above.

推荐答案

终于得到它的工作后,弄清楚它是不理想的与两个拖侦听器(你自己的和force.drag)附加到节点!

Finally got it working after figuring out it is not ideal to fight with two "drag" listeners (your own, and force.drag) attached to the nodes!

最好只有自己的drag监听器,并手动调用tick(),这是获取force图的位置节点为你在每个新的节点位置的关键特性你的节点拖动。

Much better to only have your own "drag"-listener and call tick() manually which is the key feature of getting the force graph to position the nodes for you on every new node position on the node your dragging.

工作范例: http://bl.ocks.org / 2883411

这篇关于D3力有向图与拖放支持使选定的节点位置固定时下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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