How Hooking GetNode and GetConnector Defaults Used in Core Diagram?
GetNodeDefaults
getNodeDefaults is a method we often use in our Core diagram component to customise common properties of diagram nodes. It can 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 customize common properties of connectors in the diagram component. It allows you to set properties such as:
Connector appearance: Style, shape, line width, type etc.
Refer to the code sample of the above steps:
<ejs-diagram id="diagram" width="100%" height="100%" getNodeDefaults="@ViewBag.getNodeDefaults" getConnectorDefaults="@ViewBag.getConnectorDefaults" >
@section Scripts {
<script>
function getNodeDefaults(obj, diagram) {
obj.shape = { type: 'Text' };
obj.style = { fill: '#659be5', strokeColor: 'none', color: 'white', strokeWidth: 2 };
obj.borderColor = '#3a6eb5';
obj.backgroundColor = '#659be5';
return obj;
}
function getConnectorDefaults(connector, diagram) {
connector.targetDecorator.shape = 'None';
connector.type = 'Orthogonal';
connector.style.strokeColor = 'gray';
return connector;
}
</script>
}
Below we have provided an example sample for nodeDefaults and connectorDefaults function to customize the common properties of nodes and connectors of organizational chart
Heirarchial chart :
Conclusion
I hope you enjoyed learning how hooking GetNode and GetConnector defaults used in Core Diagram.
You can refer to our ASP.NET Core 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 ASP.NET Core 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 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, Direct-Trac, or feedback portal. We are always happy to assist you!