Replace all elements and redraw graph softly in cy

2019-07-11 20:32发布

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();

1条回答
爷、活的狠高调
2楼-- · 2019-07-11 21:16

Options:

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

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

查看更多
登录 后发表回答