简体   繁体   English

使用D3表示树布局

[英]Represent a tree layout using D3

I'm trying to use D3 to create a tree layout. 我正在尝试使用D3创建树形布局。 I want to modify the standard d3 tree layout to represent a tree layout like following. 我想修改标准的d3树布局以表示如下的树布局。 In my layout, some of the child nodes can be converged into one node. 在我的布局中,某些子节点可以收敛为一个节点。 It is the only difference between that layout and the standard tree layout. 这是该布局和标准树布局之间的唯一区别。

     A
   /   \
  B     C
 /\ \   
D  E F
|  | |
G  H L
 \ // 
  J
  |
  K

In the above layout B node has 3 children(D,E,F) and each has one child node (G,H,L) and those 3 children again converge into one node (J). 在上面的布局中,B节点有3个子节点(D,E,F),每个都有一个子节点(G,H,L),并且这3个子节点再次收敛为一个节点(J)。

I can use a javascript library other than D3 also. 我也可以使用D3以外的JavaScript库。

The right way would be to use d3.layout.force instead of d3.layout.tree. 正确的方法是使用d3.layout.force而不是d3.layout.tree。

However, if you want a tree layout solution, you might want to check out http://bl.ocks.org/robschmuecker/6afc2ecb05b191359862 但是,如果您需要树形布局解决方案,则可能需要查看http://bl.ocks.org/robschmuecker/6afc2ecb05b191359862

I had a big long answer, but just if anyone actually searches this question here. 我有一个很长的答案,但就算有人在这里实际搜索此问题。 D3-Dagre D3-达格

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

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