tgdwyer / WebCola

Javascript constraint-based graph layout
http://marvl.infotech.monash.edu/webcola/
MIT License
2.01k stars 257 forks source link

Horizontal hierarchical layout (horizontal tree layout) with Webcola #236

Open karlitos opened 7 years ago

karlitos commented 7 years ago

Hi,

I am struggling with creating horizontal hierarchical layout with Cytoscape.Js and Cola. Cytoscape.Js does not support horizontal breadth first layout natively, I was hoping Cola could be the solution.

I initialize the cola layout with:

flow: { axis: 'x', minSeparation: 10 }

which leads to following layout: bildschirmfoto 2017-08-07 um 09 17 57 I was hoping to get something more like this: bildschirmfoto 2017-08-07 um 09 19 21

Is it possible to achieve such result and if, how ?

gordonwoodhull commented 7 years ago

It looks like you need a much larger separation - that's in pixels, so 10 pixels is less than the width of a node.

That said, if you want a traditional directed graph layout (like dot in graphviz) you might also try dagre. It's not maintained but it works pretty well in most cases.

karlitos commented 7 years ago

Thank you for your reply, I tried larger separation (e.g. 100px) and it improved the resulting layout. bildschirmfoto 2017-08-07 um 16 47 51

Basically I would like to get the graph as compact as possible in the vertical direction and get all the direct children nodes at the same vertical position.

I wonder if there is a possibility to define specific constraints as:

I tried dagre and it looks promising, I need to test, how it behaves in specific scenarios