Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace all elements and redraw graph softly in cytoscape.js

Is there any one-command way to replace all elements of my graph with new data in cytoscape.js? In my case, after some operations on backend I have new graph-data and want to redraw my graph with this new data, but not to lose my camera settings, maybe something like

cy.elements = my_elements;
cy.redraw();
like image 932
Alarmwolf Avatar asked Mar 03 '16 10:03

Alarmwolf


1 Answers

Options:

(1) cy.elements().remove(); cy.add( newEleJsons );

(2) cy.json({ elements: newEleJsons });

like image 85
maxkfranz Avatar answered Oct 17 '22 10:10

maxkfranz