Articles in this section

How to Convert Two Connectors into a Single Connector While Dragging and Joining in Vue Diagram

The Syncfusion® Vue Diagram allows you to merge two separate connectors into a single connector as you drag and join nodes. This can be achieved by handling the sourcePointChange and targetPointChange events, which allow you to dynamically update the source and target points of the connectors.

In this article, we will walk through the steps to handle the source and target points to convert two connectors into a single connector when one connector’s end is dragged and attached to the port of another connector.

The sourcePointChange and targetPointChange events are triggered when a connector’s source or target point is moved. These events provide an opportunity to update the source and target IDs of the connector dynamically. By handling these events, you can merge two connectors into one by removing the old connectors and updating the diagram with the new connection.

const sourcePointChange = (args) => {
 if (args.state == 'Completed') {
   var sourceConnector = diagramInstance.getObject(args.connector.sourceID);
   var sourceNode = diagramInstance.getObject((sourceConnector as any).sourceID);
   args.connector.sourceID = (sourceNode as any).id;
   diagramInstance.dataBind();
   diagramInstance.remove(sourceConnector);
   diagramInstance.clearSelection();
 }
}
const targetPointChange = (args) => {
 if (args.state == 'Completed') {
   var targetConnector = diagramInstance.getObject(args.connector.targetID);
   var targetNode = diagramInstance.getObject((targetConnector as any).targetID);
   args.connector.targetID = (targetNode as any).id;
   diagramInstance.dataBind();
   diagramInstance.remove(targetConnector);
   diagramInstance.clearSelection();
 }
}

Refer to the working sample for additional details and implementation: StackBlitz.

Conclusion

We hope you enjoyed learning how to convert two connectors into a single connector while dragging and joining using Vue Diagram.

You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied