Skip to content
Discussion options

You must be logged in to vote

Summary: Use a second, headless instance. Run the offscreen layouts there.

The following expanded explanation was generated by ChatGPT:

You can avoid mutating your live graph by spinning up a “headless” Cytoscape instance, copying in just the elements you need, running your layouts there, and then reading out the computed positions. Because there’s no container and no animation, nothing ever actually moves on-screen.

Here’s a minimal example of how you might do your two-stage DAGRE trick:

import cytoscape from 'cytoscape';
import dagre from 'cytoscape-dagre';

cytoscape.use( dagre );

// 1) grab your original graph data
const data = cy.json().elements; 

// 2) make a headless copy
const c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jackwayneright
Comment options

Answer selected by jackwayneright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants