Articles in this section

How to get the node's offset values after layout get arranged in React Diagram?

This article explains how to get a node’s offset values after the layout is arranged in React Diagram. In React Diagram, support is provided to auto-arrange the nodes in the diagram area, which is referred to as Layout. Refer to this documentation to learn more about layout.

It includes the following layout modes, such as:

  • Hierarchical layout
  • Organization chart
  • Radial tree
  • Symmetric layout
  • Mind Map layout
  • Complex hierarchical tree layout

We can retrieve the values of the offsetX and offsetY properties of the nodes from the diagram’s nodes collection after the layout has been arranged in the diagram. In the below sample, upon clicking the button, we iterate through the nodes collection, retrieve the offsetX and offsetY values of each node, and print them in the console. For more information, please refer to the code snippet and sample link below:

//Button
 <input type="button" id="getOffset" value="get-offset-values" />
 
//method to hook on clicking the button
  document.getElementById('getOffset').onclick = (args) => {
     for (let i = 0; i < diagramInstance.nodes.length; i++) {
       console.log(
         'Node' +
           (i + 1) +
           ':' +
           'OffsetX->' +
           diagramInstance.nodes[i].offsetX
       );
       console.log(
         'Node' +
           (i + 1) +
           ':' +
           'offsetY->' +
           diagramInstance.nodes[i].offsetY
       );
     }
   };

Refer to the working sample for additional details and implementation: Sample

Conclusion

We hope you enjoyed learning about how to get the node’s offset values after the layout gets arranged in React Diagram.

You can refer to our React Diagram feature tour page to learn about its other groundbreaking feature representations and documentation. You can also explore our React Diagram example to understand how to present and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our React Diagram and other components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied