We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Can't stringify diagram event

I am trying to print out the event from 'click' on the diagram, and getting exception.

I simply have an empty diagram with nothing on it..

<DiagramComponent id="diagram"
ref={diagram => (diagramInstance = diagram)}
width={"100%"} height={"1000px"}
type: "ComplexHierarchicalTree",
verticalSpacing: 30,
horizontalSpacing: 40,
enableAnimation: true
click={(e) => { self.diagramSelected(e) }}
<Inject services={[ComplexHierarchicalTree, LayoutAnimation]} />

I get this error:
TypeError: JSON.stringify cannot serialize cyclic structures

simply trying to do this:
click={(e) => { self.diagramSelected(e) }}

diagramSelected(e) {
console.log(`selection changed `, JSON.stringify(e));

3 Replies

SG Shyam G Syncfusion Team November 14, 2019 10:53 AM UTC

Hi Raphael, 
The cyclic error forms when an object holds a reference to another object. So we have a cyclic structure formed in our nodes. Please refer to the below node to know more about cyclic structure. If you need to serialize a diagram object, please use a saveDiagram method which will return the serialized json model object. Please refer to a help documentation below. 

Shyam G 

RC raphael chancey November 14, 2019 02:47 PM UTC

ok.. makes sense.. thank you

SG Shyam G Syncfusion Team November 15, 2019 12:37 AM UTC

Hi Raphael, 
Thanks for your update. 
Shyam G 

Live Chat Icon For mobile
Up arrow icon