jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.81k stars 2.06k forks source link

How to clear the graph and create a new one ? #474

Closed rudaoshi closed 3 years ago

rudaoshi commented 4 years ago
  1. deleting all cells does not clear the shown graph
  2. clear() the model results in adding new vertex failed.
tbouffard commented 4 years ago

@rudaoshi can you please provide more detatils?

PrudhviMadasu commented 4 years ago

Try this, it works for me graph.removeCells(graph.getChildVertices(graph.getDefaultParent()));

nayaksnigdha commented 4 years ago

I am also facing the same issue as @rudaoshi. If I invoke graph.removeCells(graph.getChildVertices(graph.getDefaultParent())); as suggested, the vertices are removed but if there are dangling edges (unconnected edges) in the graph they are not removed. If I invoke model.clear() everything gets deleted, even dangling edges but then adding new vertex fails.