addCell(Link)

34 views
Skip to first unread message

che

unread,
May 10, 2022, 1:15:52 AM5/10/22
to JointJS
Hi there,

I draw many elements using "jsonObject = graph.toJSON();" this line.
Then I saved jsonObject in Mongo and load it on graph but only link is not presenting.

Here is the jsonObject.
1.JPG

And I used following code to draw link.
````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
elements.cells.forEach(element => {
            if(element['type'] == "link") {
                graph.addCell(element);
            }
        });
````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

I thought problem was target and source elements is existing yet. So, I draw other rec and custom elements first and draw link later but end up with this error message.

Capture.JPG 
2.JPG

Do you know what does this message mean?


Many thanks!

Roman Bruckner

unread,
May 10, 2022, 3:36:39 AM5/10/22
to joi...@googlegroups.com
It means that the source or target of a link does not exist in the graph.

link.set('target', { id: 'non-existing-element-id' }); would throw the same error.





--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/2e1cfb87-6042-4ad2-b909-72281cf4ec52n%40googlegroups.com.


--

che

unread,
May 10, 2022, 8:44:04 PM5/10/22
to JointJS
Thanks! I've just solved the problem. 
Reply all
Reply to author
Forward
0 new messages