Articles in this section

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

This article explains how to get the node's offset values after the layout gets arranged in JavaScript Diagram.

Diagram provides support to auto-arrange the nodes in the diagram area, which is referred to as a 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:

document.getElementById('getValues').onclick = function () {  
for (let i = 0; i < diagram.nodes.length; i++) {
    console.log('Node' + (i + 1) + ':' + 'OffsetX->' + diagram.nodes[i].offsetX);    
console.log('Node' + (i + 1) + ':' + 'offsetY->' + diagram.nodes[i].offsetY); 
}
};

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

You can also refer to our Diagram documentation to know more.


Conclusion


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

You can refer to our JavaScript Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our JavaScript Diagram example to understand how to create 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 other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsBoldDesk 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