user3607722
user3607722

Reputation: 3

Cytoscape.js: Needed linear layout

I am trying to use cytoscape.js to create network diagram. There are couple of layout which will design nodes and links from upward to downward. One of them is "dagre" layout. But, what I want is do display the same layout from left to right. But I have no luck to find such option.

Is there a way I can achieve this. I am sharing an image url. http://share.pho.to/9M6Sa . It is the combination of two images A) What I am getting using "dagre" layout B) What I needed.

Any help will be greatly appreciated.

Thanks

Upvotes: 0

Views: 718

Answers (2)

Vishal Tanwar
Vishal Tanwar

Reputation: 21

var cy = window.cy = cytoscape({ container : document.getElementById('cy'),

    boxSelectionEnabled : true,
    autounselectify : true,

    layout : {
        name: 'dagre',
        rankDir: 'LR' // this is left to right , dagre options(rankDir)
    },

Upvotes: 2

maxkfranz
maxkfranz

Reputation: 12250

Chop's suggestion is a good one, especially since many layouts are just wrappers external libraries like Dagre. An example of his suggestion in practice:

cy.one('layoutstop', function(){
  cy.nodes.positions(function(n){
    var pos = n.position();
    return { x: pos.y, y: pos.x };
  });

  cy.fit(); // fit to new node positions
}).layout({ /* my options... */ });

Upvotes: 3

Related Questions