0

I would like to change the model of the current graph displayed.

With Java (JGraph) I can use graph.setModel(...) but there is no such method in JavaScript. What is the best way to do this ?

Xavier M.
  • 136
  • 1
  • 7

2 Answers2

1

You can use graph.model directly

Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55
  • Thank you @David, maybe we are doing something wrong but when doing this the cells from the old model are still displayed (but are not present is the model). – Xavier M. Dec 13 '19 at 08:12
0

You can clear the graph by either calling

graph.removeCells(graph.getChildVertices(graph.getDefaultParent()));

or

graph.getModel().clear();

and setting a new model afterwards. In my experience, you have to additionally remove the html of the graph container, to truly erase all content (otherwise you get some weird white space in there).

$("#container").html("");
Philipp Poropat
  • 131
  • 1
  • 6