Using yFiles layouts in cytoscape.js

835 Views Asked by At

I am new to cytoscape.js. I want to use hierarchical layout from yFiles layouts in cytoscape. Is there a way to specify this layout in json file?

Thanks, Rtut

1

There are 1 best solutions below

0
On

You can make a layout extension using the yFiles algorithm. That will make the yFiles layout a reusable Cytoscape layout. You could alternatively just update the positions ad-hoc based on yFiles output, but it's really easy and beneficial to make an extension.

If you just want to specify positions at init: Nodes are positioned wherever you specify in the position field in the element JSON.

You can call node.position() or nodes.positions() on elements that already exist. Layout extensions tend to use nodes.positions() (more manual) or nodes.layoutPositions() (easier).

If you do decide to make an extension, please publish it. The process of building and publishing an extension is fully automated, so it gives you nice modularity and it gives other devs the opportunity to try out and contribute to your layout.