Assign Connector Segments at Runtime

Is it possible to add connector segments at runtime?  I would like my connector to be Orthogonal instead of straight.

I have tried the following but "Segments is not defined".  Note, I have also tried just "segments: Orthogonal" and both as lowercase also.

<script>
function addReportNode() {

            var diagram = $("#Diagram").ejDiagram("instance");

            // Defines JSON to create a node
            var reportNode = {
                name: "reportNode",
                offsetX: 550,
                offsetY: 240,
                height: 80,
                width: 200,
                fillColor: "rgb(75, 205, 150)",
                type: ej.datavisualization.Diagram.Shapes.Html,
                templateId: "htmlReportTemplate",
            };

            var connector = {
                segments: Segments.Orthogonal,
                sourceNode: "sourceNode",
                targetNode: "reportNode"
            }
            // Adds node to the Diagram
            diagram.add(reportNode);
            diagram.add(connector);
        }
</script>

1 Reply 1 reply marked as answer

AR Aravind Ravi Syncfusion Team July 23, 2020 05:30 AM UTC

Hi Dsoftware, 
 
To show connector segments as orthogonal , set connector segment as Orthogonal. If you want to set connector segment as orthogonal means then set connector segment type as Orthogonal and connector segments is array type. To access any diagram properties get the properties from the diagram and access the required property as  ej.datavisualization.Diagram.Segments.Orthogonal. Please refer below code example 
 
var connectors = 
        // Defines JSON 
        { 
            //Name of the connector 
            name: "newConnector", 
            //Sets source and target points 
            sourcePoint: { 
                x: 700, 
                y: 100 
            }, 
            targetPoint: { 
                x: 900, 
                y: 250 
            }, 
            segments: [{ type: ej.datavisualization.Diagram.Segments.Orthogonal}] 
                         
        }; 
 
 
 
Regards 
Aravind Ravi 


Marked as answer
Loader.
Up arrow icon