How to layout a non-tree hierarchy with D3

后端 未结 4 1967
感情败类
感情败类 2020-12-13 04:41

D3 has a variety of layouts for directed graphs that are strict trees, such as the following:

A
|\\
B C
 / \\
D   E

I need to draw a hierar

4条回答
  •  不思量自难忘°
    2020-12-13 05:10

    As this example: "Force Directed Trees" illustrates there is a trick that often works. In the example the force direction's behavior is adjusted on each tick so that nodes drift slightly up or down depending on the direction of the links. As shown this will do a fine job for trees, but I've found it also works tolerable well for acyclic graphs. No promises, but it may help.

提交回复
热议问题