get the postion (offsetX and offsetY) values of steps after Hierarchical layout implementation

Hi,
Can I get all the nodes (offsetX and offsetY) values collectively after Lyout Hhierarical is selected from front end. So that I can save their postions in database?

5 Replies 1 reply marked as answer

AR Aravind Ravi Syncfusion Team July 21, 2020 04:25 AM UTC

Hi Rakhi, 
 
We have created a sample to get the node offset values from the hierarchical tree. After the layout gets arranged in the diagram through diagram nodes property you can get the node offset position. In the node’s offsetX and offsetY position we can get where the node gets rendered in the diagram. So by using the node’s offsetX and offsetY position you get the node position and stored in the data base. Please refer below code example and sample below 
 
public getValues() { 
     for(let i: number = 0; i < this.diagram.nodes.length ; i++) { 
       console.log("Node" + (i+1) + ":" + "OffsetX->" + this.diagram.nodes[i].offsetX); 
       console.log("Node" + (i+1) + ":" + "offsetY->" + this.diagram.nodes[i].offsetY); 
     } 
   } 
 
 
Regards 
Aravind R 



RA RakhiS replied to Aravind Ravi July 27, 2020 08:43 AM UTC

Hi Rakhi, 
 
We have created a sample to get the node offset values from the hierarchical tree. After the layout gets arranged in the diagram through diagram nodes property you can get the node offset position. In the node’s offsetX and offsetY position we can get where the node gets rendered in the diagram. So by using the node’s offsetX and offsetY position you get the node position and stored in the data base. Please refer below code example and sample below 
 
public getValues() { 
     for(let i: number = 0; i < this.diagram.nodes.length ; i++) { 
       console.log("Node" + (i+1) + ":" + "OffsetX->" + this.diagram.nodes[i].offsetX); 
       console.log("Node" + (i+1) + ":" + "offsetY->" + this.diagram.nodes[i].offsetY); 
     } 
   } 
 
 
Regards 
Aravind R 


Thank you for the reply,
Also can I get the ids of nodes with their offsetx and offsety values?

Thanks


AR Aravind Ravi Syncfusion Team July 28, 2020 04:21 AM UTC

Hi Rakhi, 

By using the node ID property you can get the node’s id after hierarchical layout arranged in diagram. Please refer to below code snippet for how to get node’s ID . 

public getValues() { 
     for(let i: number = 0; i < this.diagram.nodes.length ; i++) { 
       console.log("Node" + (i+1) + ":" + "ID->" + this.diagram.nodes[i].id); 
    
  


Regards 
Aravind Ravi 


Marked as answer

RA RakhiS July 29, 2020 11:18 AM UTC

Thanks it worked


AR Aravind Ravi Syncfusion Team July 30, 2020 04:03 AM UTC

Hi Rakhi, 
 
Thanks for the update. 
 
Regards 
Aravind Ravi 


Loader.
Up arrow icon