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
close icon

How to set the shape in getNodeDefaults

I am using this code from one of the examples but anything I do to set the shape has no impact..

setting shape obj in fact just breaks things.. 

I was trying set it to a circle.. 




function nodeDefaults(obj, diagram) {
obj.style = {
fill: "#659be5",
strokeColor: "none",
color: "white",
strokeWidth: 2
};
obj.borderColor = "#3a6eb5";
obj.backgroundColor = "#659be5";
obj.shape.margin = { left: 5, right: 5, bottom: 5, top: 5 };
obj.expandIcon = {
height: 10,
width: 10,
shape: "None",
fill: "lightgray",
offset: { x: 0.5, y: 1 }
};
obj.expandIcon.verticalAlignment = "Auto";
obj.expandIcon.margin = { left: 0, right: 0, top: 0, bottom: 0 };
obj.collapseIcon.offset = { x: 0.5, y: 1 };
obj.collapseIcon.verticalAlignment = "Auto";
obj.collapseIcon.margin = { left: 0, right: 0, top: 0, bottom: 0 };
obj.collapseIcon.height = 10;
obj.collapseIcon.width = 10;
obj.collapseIcon.padding.top = 5;
obj.collapseIcon.shape = "None";
obj.collapseIcon.fill = "lightgray";
return obj;
}

1 Reply

SG Shyam G Syncfusion Team November 11, 2019 05:58 AM UTC

Hi Raphael, 

We have created an sample in which we have set a node shape property in getNodeDefaults function and it is working fine at our end. Could you please check in the below sample?. Still, if you face any issues, please share us more details such as modify the below sample. 

Code example: 
<DiagramComponent id="diagram" ref={diagram => (diagramInstance = diagram)} width={"100%"} height={"590px"}   
         getNodeDefaults={(obj, diagram) => { 
            obj.height = 50; 
            //set an shape 
            obj.shape = { 
              type: 'Basic', shape: 'Ellipse' 
            } 
            obj.style = { fill: "transparent", strokeWidth: 2 }; 
            return obj; 
        }}   
       
              <Inject services={[DataBinding, HierarchicalTree]}/> 
            </DiagramComponent> 



Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon