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"}
layout={{
type: "ComplexHierarchicalTree",
verticalSpacing: 30,
horizontalSpacing: 40,
enableAnimation: true
}}
click={(e) => { self.diagramSelected(e) }}
>
<Inject services={[ComplexHierarchicalTree, LayoutAnimation]} />
</DiagramComponent>



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 05:53 AM

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. 
 


 
Regards, 
Shyam G 



RC raphael chancey November 14, 2019 09:47 AM

ok.. makes sense.. thank you


SG Shyam G Syncfusion Team November 14, 2019 07:37 PM

Hi Raphael, 
Thanks for your update. 
Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon