How to Hook GetNodeDefaults and GetConnectorDefaults in Angular Diagram?
This article explains how to hook GetNodeDefaults and GetConnectorDefaults in Angular Diagram.
GetNodeDefaults
getNodeDefaults is a method often we use in our Angular Diagram component to customise common properties of diagram nodes. It could return or allow you to set properties such as:
Node appearance: Size, shape, color, border, etc.
Node data structure: Initial attributes like width, height and etc.
GetConnectorDefaults
Similar to getNodeDefaults, getConnectorDefaults is also a method used to customise common properties of connectors in diagram component. It allow you to set properties such as:
Connector appearance: Style, shape, line width, type etc.
Refer to the code sample to hook getNodeDefaults and getConnectorDefaults in org-chart layout:
<ejs-diagram
#diagram
id="diagram"
width="100%"
height="700px"
[getConnectorDefaults]="connectorDefaults"
[getNodeDefaults]="nodeDefaults"
[layout]="layout"
[dataSourceSettings]="data"
>
</ejs-diagram>
//Defines the default node and connector properties
public nodeDefaults(node: NodeModel): NodeModel {
node.backgroundColor = (node.data as EmployeeInfo).color;
node.style = { fill: 'none', strokeColor: 'none', color: 'white' };
node.width = 120;
node.height = 30;
return node;
}
public connectorDefaults(connector: any, diagram: Diagram): ConnectorModel {
connector.targetDecorator.shape = 'None';
connector.type = 'Orthogonal';
connector.constraints = ConnectorConstraints.None;
connector.cornerRadius = 0;
return connector;
}
Below we have provided an example sample for nodeDefaults and connectorDefaults functions to customize the common properties of nodes and connectors in an organizational chart.
Organization chart :Sample
Conclusion
We hope you enjoyed learning how to hook GetNodeDefaults and GetConnector 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!