multiple graphs in one instance

1.2k views Asked by At

I'm making view of my switch with cytoscape. Switch has about 40 ports, each port fits nice to the breadthfirst layout.

https://i.stack.imgur.com/Ddg2D.png

But I need around 40 about same graphs in one page

When I'm using breadthfirst with multiple roots I'm getting mess like this

https://i.stack.imgur.com/nYcNz.png

So, can I deal with this somehow?

Sorry, dont have 10 rep yet, so cant paste images and more links to explain more correctly.

Also english not my native language.

2

There are 2 answers

0
maxkfranz On BEST ANSWER

You can run different layouts on different parts of the graph, if you want to keep all elements in a single instance: http://js.cytoscape.org/#collection/layout

0
DanielBoloc On

Have you looked at this example?: http://jsbin.com/gist/310dca83ba6970812dd0?js,output

It is basically the same that you want to do. Just add in your body tag:

<body>
    <div id="cyFirstInstance"></div>
    <div id="cySecondInstance"></div>
</body>

And in your javascript function where you define the nodes, add for each instance the style (it could be the same for both nodes)

$('#cyFirstInstance').cytoscape({
    style: ...

$('#cySecondInstance').cytoscape({
    style: ...

Hope this helps.