Reset a Cytoscape Graph

I just observed that there are too many questions regarding resetting a cytoscape.js graph to its originally loaded state.

Following is a simple function you need to call to reset the graph:

cy.layout();

You can bind it to click events as and when needed.

Cheers!

Upvotes: 2

Views: 2468

Answers (1)

To reset to original state:

cy.layout();

To fit the randomly panned/zoomed graph to the div:

cy.fit();

Hope it helps!

Upvotes: 1

Related Questions