Add bulks of elements as JSON #1778
Answered
by
kumilingus
seekeramento
asked this question in
Q&A
-
We can use graph.fromJSON to add a bulk of cells at once as JSON. However, this clears the graph everytime. In my case, I want to add batches of operations; each batch as JSON. However, each batch clears the previous once. Which API would be recommended in my case? |
Beta Was this translation helpful? Give feedback.
Answered by
kumilingus
Aug 12, 2022
Replies: 1 comment 1 reply
-
The graph.addCells([{
type: 'standard.Rectangle',
size: { width: 100, height: 100 }
}, {
type: 'standard.Ellipse',
size: { width: 200, height: 100 }
}]); Instead of graph.addCells(json.cells); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
seekeramento
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
dia.Graph.prototype.addCells
method also accepts an array of JSON cells.Instead of
graph.fromJSON(json)
, the following can be called to preserve existing cells: