How to Hook GetNodeDefaults and GetConnectorDefaults in Vue Diagram?
GetNodeDefaults
getNodeDefaults is a method often we use in our Vue Diagram component to customize 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 to hook getNodeDefaults and getConnectorDefaults in org-chart layout:
<template>
<ejs-diagram
style="display: block"
ref="diagramObj"
id="diagram"
:width="width"
:height="height"
:tool="tool"
:layout="layout"
:getNodeDefaults="getNodeDefaults"
:getConnectorDefaults="getConnectorDefaults"
:dataSourceSettings="dataSourceSettings"
></ejs-diagram>
</template>
// Sets default value for Node.
function getNodeDefaults(obj, diagram) {
obj.backgroundColor = obj.data.color;
obj.style = { fill: 'none', strokeColor: 'none', color: 'white' };
obj.width = 120;
obj.height = 30;
return obj;
}
// Sets default value for Connector.
function getConnectorDefaults(connector, diagram) {
if (connector.targetDecorator) connector.targetDecorator.shape = 'None';
connector.type = 'Orthogonal';
connector.constraints = 0;
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 Vue Diagram.
You can refer to our Vue 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 Vue 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!