Cytoscape.js can calculate a layout for a graph file that does not have layout information, but being a JavaScript library, this calculation happens every time a user visits the web application and thus slows down the page load.
Cytoscape Desktop can import the graph, calculate the layout and export it back to Cytoscape.js but this complicates the process.
Is it possible to save or cache the layout with just Cytoscape.js?
You can save the entire graph with positions using cy.json()
. Or, you can grab positions via node.position()
and set this in your elements JSON at init manually.
Just use the preset layout at init to use preset positions: http://js.cytoscape.org/#layouts/preset