D3强制定向图节点 [英] D3 Force Directed Graph nodes in order
本文介绍了D3强制定向图节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Force Directed Graph来构建一种流程图。它工作正常,除了节点没有特定的顺序。它们是随机的。我希望图表遵循层次结构的顺序。
I am using the Force Directed Graph to build a kind of flow diagram. It works fine except that the nodes have no specific order. They are random. I would like the graph to follow a hierarchical order.
var force = d3.layout.force()
.nodes(d3.values(nodes))
.links(links)
.size([width, height])
.linkDistance(90)
.gravity(0.6)
.charge(-2000)
.linkStrength(0.3);
我想给节点一些
推荐答案
p>您可以使用强制布局与定量焦点,所以节点位于其数值层次结构。来自Mike的讲座(和验证码)的演示:
You can use the force layout with a quantitative foci so the nodes are located based in its numerical hierarchy. A demo from Mike's talk (and the code):
- Demo
- Code
回答
这篇关于D3强制定向图节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文