Directed, acyclic graph in d3.js

风流意气都作罢 提交于 2019-12-04 08:37:19

问题


Is there a reliable way of drawing directed, acyclic graphs in D3.js today? I'm trying to visualize prerequisites in a curriculum, similar to this.

I've seen some older answers to similar questions with the most promising lead being this hack, though it doesn't work reliably well with larger and more complex data sets.

Is this simply a rare case of a visualization that D3 is not ideal for?


回答1:


You may have a try to dagre, a JS library for DAG graphs.

If you want to use d3 for whatever reason, have a look at dagre-d3

For a more high-level approach have a look at this project using all the libs above.

If d3 is not mandatory have also a look at others graphs library. ;)

Update for September 2018

There is a new library , called d3-dag




回答2:


Way late but perhaps relevant to others searching for similar information...

Elkjs supports layered graph layout and appears to still be actively maintained at this time.

Some suggested layout options based on the OP's usecase...

layoutOptions: {
        'org.eclipse.elk.algorithm': 'layered',
        'org.eclipse.elk.direction' : 'DOWN',
        'org.eclipse.elk.edgeRouting': 'SPLINES',
        'org.eclipse.elk.layered.edgeRouting.sloppySplineRouting': false,
        'org.eclipse.elk.layered.layering.strategy': 'INTERACTIVE' }

These options can be pasted into this interactive editor to see how the layout is affected.



来源:https://stackoverflow.com/questions/26636643/directed-acyclic-graph-in-d3-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!