How to get the node's offset values after layout get arranged in Angular Diagram?
This article explains how to get the node’s offset values after the layout is arranged in an Angular diagram. Angular Diagram provides support to auto-arrange the nodes in the diagram area, which is referred to as a layout. Refer to this documentation to learn more about layouts.
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 sample below, 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.
Refer to the code snippet and sample link below:
app.component.html
<input type="button" value="get-offset-Value" (click)="getOffset()" />
app.component.ts
public getOffset() {
for (let i = 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
);
}
}
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 Angular Diagram.
You can refer to our Angular Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular 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 forums, BoldDesk Support, or feedback portal. We are always happy to assist you!