dagrejs / dagre

Directed graph layout for JavaScript
MIT License
4.72k stars 606 forks source link

How can I set layout options? For example, I want to change rankdir to LR. #300

Open miyabi-o opened 4 years ago

miyabi-o commented 4 years ago

Hi, first of all, I want to say big thanks for open sourcing this project! It helps me a lot!

Btw, I want to change the direction of the graph from TB to LR, and I tried simply setting the rankdir property to LR but it didn't work.

This must be noob question, but if you have time, could you tell me how to set layout options such as rankdir or nodesep?

izhan commented 4 years ago

I found it helpful to follow https://github.com/dagrejs/dagre/wiki#an-example-layout

To configure layout options, pass the a config object to setGraph e.g.

g.setGraph({rankdir: "LR", ranker: "network-simplex", align: "UL" });
mcdemarco commented 4 years ago

I found it helpful to follow https://github.com/dagrejs/dagre/wiki#an-example-layout

I found it unhelpful because it did not provide any information about how or where to set the layout options.

To configure layout options, pass the a config object to setGraph e.g.

g.setGraph({rankdir: "LR", ranker: "network-simplex", align: "UL" });

The format of the "second arg" of layout for setting the same layout options also needs documentation.

KutnerUri commented 4 years ago

thanks for this, I thought I should add these options at .layout(g)