Articles in this section

How to Update Orthogonal Segments in JavaScript Diagram Connectors?

To update orthogonal segments when a connector is drawn dynamically from one port to another, you can utilize the CollectionChange event. When a connector is added or removed, the JavaScript Diagram connector collection is modified, which triggers the collectionChange event. This event is triggered twice during the process-once in the “changing” state and again in the “changed” state once the action has been completed.

Below is a code example demonstrating how to update orthogonal segments when dynamically drawing a connectors:

We can draw the connector from the port by enabling draw constraints on the port.

       constraints:
         ej.diagrams.PortConstraints.Default |
         ej.diagrams.PortConstraints.Draw,

When the connector is drawn, the event is triggered and updates the segments of an orthogonal connector when the connector’s state changes to ‘Changed’.

collectionChange: function (args) {
    if (args.state === 'Changed' && args.element.type == 'Orthogonal') {
       let connector = args.element;
       connector.segments = [
         {
           type: 'Orthogonal',
           direction: 'Right',
           length: 70,
         },
       ];
     }
   }, 

Sample

Conclusion

I hope you enjoyed learning how to update orthogonal segments in JavaScript Diagram connectors.
You can refer to our JavaScript 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 JavaScript 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!

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