简体   繁体   中英

Represent a tree layout using D3

I'm trying to use D3 to create a tree layout. I want to modify the standard d3 tree layout to represent a tree layout like following. 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).

I can use a javascript library other than D3 also.

The right way would be to use d3.layout.force instead of d3.layout.tree.

However, if you want a tree layout solution, you might want to check out http://bl.ocks.org/robschmuecker/6afc2ecb05b191359862

I had a big long answer, but just if anyone actually searches this question here. D3-Dagre

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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