How to Change Node and Connector Shape of the Vue Diagram Dynamically?
The Syncfusion® Vue Diagram control provides support for adding various shapes to nodes and connectors. These shapes are categorized as follows:
Node Shapes:
- Node shapes
- Text node
- Image node
- HTML node
- Native node
- Basic shapes
- Flow shapes
- BPMN shapes
- UML diagram shapes
Connector Types:
The Diagram supports different connector types, including:
- Straight
- Orthogonal
- Bezier
Additionally, connectors of distinct shapes are available for different node shapes. Specific connector shapes are applicable to BPMN flow lines, UML relationships, and UML class connectors.
To change the shape of the node or Connector dynamically at run time with the button click refer the code below
<ejs-button :isPrimary="true" v-on:click="btnClick">shapeChange</ejs-button>
<ejs-diagram style='display:block' ref="diagramObj" id="diagram" :width='width' :height='height' :nodes='nodes' :connectors= connectors>
</ejs-diagram>
function shapeChange() {
for (let i = 0; i < diagramInstance.connectors.length; i++) {
let connector = diagramInstance.connectors[i];
connector.type = 'Bezier';
}
for (let i = 0; i < diagramInstance.nodes.length; i++) {
let node = diagramInstance.nodes[i];
node.shape = {
type: 'Flow',
shape: 'Decision'
}
}
diagramInstance.dataBind();
}
You can find a working example of this implementation in the provided sample on StackBlitz.
Conclusion
I hope you enjoyed learning how to change the node and connector shapes of the Vue Diagram dynamically.
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, Direct-Trac, or feedback portal. We are always happy to assist you!