Skip to content

Add bulks of elements as JSON #1778

Answered by kumilingus
seekeramento asked this question in Q&A
Discussion options

You must be logged in to vote

The dia.Graph.prototype.addCells method also accepts an array of JSON cells.

graph.addCells([{
  type: 'standard.Rectangle',
  size: { width: 100, height: 100 }
}, {
  type: 'standard.Ellipse',
  size: { width: 200, height: 100 }
}]);

Instead of graph.fromJSON(json), the following can be called to preserve existing cells:

graph.addCells(json.cells);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@seekeramento
Comment options

Answer selected by seekeramento
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants