diff --git a/blazor/diagram/connectors/customization.md b/blazor/diagram/connectors/customization.md index 5bf39fa826..9eb8a293ed 100644 --- a/blazor/diagram/connectors/customization.md +++ b/blazor/diagram/connectors/customization.md @@ -734,6 +734,96 @@ The following code example illustrates how to set the connection padding value f } ``` You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Connectors/Customization/ConnectionPadding) + +### How to enable Connector Split + +Connectors are used to create links between two points, ports, or nodes to represent the relationships between them. By enabling the [EnableConnectorSplitting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html#Syncfusion_Blazor_Diagram_SfDiagramComponent_EnableConnectorSplitting) property, you can split a connector between two nodes when a new node is dropped onto the existing connector. This action creates a connection between the new node and the existing nodes. By default, [EnableConnectorSplitting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html#Syncfusion_Blazor_Diagram_SfDiagramComponent_EnableConnectorSplitting) is set to false. + +The following code illustrates how to enable connector splitting and create connections with a new node. +```cshtml +@using Syncfusion.Blazor.Diagram + + + +@code { + //Reference the diagram + SfDiagramComponent Diagram; + // Initialize diagram's connector collection + DiagramObjectCollection connectors = new DiagramObjectCollection(); + // Initialize diagram's node collection + DiagramObjectCollection nodes = new DiagramObjectCollection(); + protected override void OnInitialized() + { + nodes = new DiagramObjectCollection() { + new Node() { OffsetX = 100, + OffsetY = 100, + Height = 50, + Width = 100, + ID = "node1", + Style = new ShapeStyle(){ Fill = "#6495ED", + StrokeColor = "#6495ED",}, + Shape = new BasicShape() { Type = NodeShapes.Basic, Shape = NodeBasicShapes.Rectangle } + }, + new Node() { OffsetX = 300, + OffsetY = 300, + Height = 50, + Width = 100, + ID = "node2", + Style = new ShapeStyle(){ Fill = "#6495ED", + StrokeColor = "#6495ED",}, + Shape = new BasicShape() { Type = NodeShapes.Basic, Shape = NodeBasicShapes.Rectangle } + }, + new Node() { OffsetX = 300, + OffsetY = 100, + Height = 50, + Width = 100, + ID = "node3", + Style = new ShapeStyle(){ Fill = "#6495ED", + StrokeColor = "#6495ED",}, + Shape = new BasicShape() { Type = NodeShapes.Basic, Shape = NodeBasicShapes.Rectangle } + } + }; + Connector Connector = new Connector() + { + ID = "connector1", + //Source node id of the connector. + SourceID = "node1", + TargetDecorator = new DecoratorSettings() + { + Style = new ShapeStyle() + { + Fill = "#6495ED", + StrokeColor = "#6495ED", + } + }, + //Target node id of the connector. + TargetID = "node2", + Style = new ShapeStyle() + { + Fill = "#6495ED", + StrokeColor = "#6495ED", + }, + // Type of the connector + Type = ConnectorSegmentType.Straight, + Constraints = ConnectorConstraints.Default | ConnectorConstraints.AllowDrop, + }; + connectors.Add(Connector); + } +} +``` +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Interaction) + +>**Note:** The [AllowDrop](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.ConnectorConstraints.html#Syncfusion_Blazor_Diagram_ConnectorConstraints_AllowDrop) constraints must be enabled for the connector to allow dropping a node. + +### Create connection using Connector splitting + +When a node is dropped on a point-to-point connection, it connects as the source for the target connector. +Dropping another node on the target connector with only a source connection will connect the dropped node as its target, creating a complete connection. + +If a node is dropped on an existing node-to-node connection, the connector between the two nodes splits, creating a connection between the new node and the existing nodes. + +![ConnectorSplitting](../images/ConnectorSplitDemo.gif) + ## See also * [How to interact with the connector](./interactions) diff --git a/blazor/diagram/images/ConnectorSplitDemo.gif b/blazor/diagram/images/ConnectorSplitDemo.gif new file mode 100644 index 0000000000..aced363163 Binary files /dev/null and b/blazor/diagram/images/ConnectorSplitDemo.gif differ diff --git a/blazor/diagram/interaction.md b/blazor/diagram/interaction.md index 35699443c7..02b9a65c11 100644 --- a/blazor/diagram/interaction.md +++ b/blazor/diagram/interaction.md @@ -732,4 +732,4 @@ The following table illustrates those commands with the associated key values. ## See Also -* [How to control the diagram history](./undo-redo) \ No newline at end of file +* [How to control the diagram history](./undo-redo)