Skip to content

Commit 3b573ec

Browse files
Copilotdwarwick
andcommitted
Fix unterminated connectors by removing manual segments - use natural orthogonal routing
Co-authored-by: dwarwick <15970276+dwarwick@users.noreply.github.com>
1 parent 46acf43 commit 3b573ec

File tree

1 file changed

+4
-88
lines changed

1 file changed

+4
-88
lines changed

JwtIdentity.Client/Pages/Survey/BranchingSurveyEdit.razor.cs

Lines changed: 4 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,7 @@ private void BuildSyncfusionDiagram()
746746

747747
private void CreateConnectorsWithWaypoints(Dictionary<int, double> groupPositions, Dictionary<string, (double x, double y)> optionNodePositions)
748748
{
749-
const double routingClearance = 80; // Distance below nodes to route connectors
750-
const double connectorSpacing = 25; // Vertical spacing between parallel connectors
751-
752-
// Track connectors going to each target group to apply vertical spacing
749+
// Track connectors going to each target group
753750
var connectorsToTarget = new Dictionary<int, int>();
754751

755752
foreach (var question in Survey.Questions.OrderBy(q => q.QuestionNumber))
@@ -766,8 +763,6 @@ private void CreateConnectorsWithWaypoints(Dictionary<int, double> groupPosition
766763

767764
// Get positions
768765
if (!optionNodePositions.ContainsKey(optionNodeId)) continue;
769-
var (sourceX, sourceY) = optionNodePositions[optionNodeId];
770-
var targetX = groupPositions[branchToGroupId];
771766

772767
// Determine source and target ports
773768
var sourcePortId = DetermineSourcePort(sourceGroupNumber, branchToGroupId);
@@ -781,87 +776,9 @@ private void CreateConnectorsWithWaypoints(Dictionary<int, double> groupPosition
781776
var connectorIndex = connectorsToTarget[branchToGroupId];
782777
connectorsToTarget[branchToGroupId]++;
783778

784-
// Calculate waypoints with vertical spacing
785-
var segments = new DiagramObjectCollection<ConnectorSegment>();
786-
787-
// Calculate routing Y position below the source node
788-
var routingY = sourceY + routingClearance + (connectorIndex * connectorSpacing);
789-
790-
// Determine routing direction
791-
if (targetX > sourceX)
792-
{
793-
// Routing to the right
794-
// 1. Exit right from source
795-
// 2. Go down to routing level
796-
// 3. Go right to target X area
797-
// 4. Go up to target
798-
799-
var horizontalDistance = targetX - sourceX;
800-
801-
// Use point-to-point segments for precise routing
802-
segments.Add(new OrthogonalSegment()
803-
{
804-
Type = ConnectorSegmentType.Orthogonal,
805-
Length = 30, // Exit right a bit
806-
Direction = Syncfusion.Blazor.Diagram.Direction.Right
807-
});
808-
segments.Add(new OrthogonalSegment()
809-
{
810-
Type = ConnectorSegmentType.Orthogonal,
811-
Length = routingClearance + (connectorIndex * connectorSpacing),
812-
Direction = Syncfusion.Blazor.Diagram.Direction.Bottom
813-
});
814-
segments.Add(new OrthogonalSegment()
815-
{
816-
Type = ConnectorSegmentType.Orthogonal,
817-
Length = horizontalDistance - 30,
818-
Direction = Syncfusion.Blazor.Diagram.Direction.Right
819-
});
820-
segments.Add(new OrthogonalSegment()
821-
{
822-
Type = ConnectorSegmentType.Orthogonal,
823-
Direction = Syncfusion.Blazor.Diagram.Direction.Top
824-
});
825-
}
826-
else if (targetX < sourceX)
827-
{
828-
// Routing to the left
829-
var horizontalDistance = sourceX - targetX;
830-
831-
segments.Add(new OrthogonalSegment()
832-
{
833-
Type = ConnectorSegmentType.Orthogonal,
834-
Length = 30, // Exit left a bit
835-
Direction = Syncfusion.Blazor.Diagram.Direction.Left
836-
});
837-
segments.Add(new OrthogonalSegment()
838-
{
839-
Type = ConnectorSegmentType.Orthogonal,
840-
Length = routingClearance + (connectorIndex * connectorSpacing),
841-
Direction = Syncfusion.Blazor.Diagram.Direction.Bottom
842-
});
843-
segments.Add(new OrthogonalSegment()
844-
{
845-
Type = ConnectorSegmentType.Orthogonal,
846-
Length = horizontalDistance - 30,
847-
Direction = Syncfusion.Blazor.Diagram.Direction.Left
848-
});
849-
segments.Add(new OrthogonalSegment()
850-
{
851-
Type = ConnectorSegmentType.Orthogonal,
852-
Direction = Syncfusion.Blazor.Diagram.Direction.Top
853-
});
854-
}
855-
else
856-
{
857-
// Same group - simple vertical connection
858-
segments.Add(new OrthogonalSegment()
859-
{
860-
Type = ConnectorSegmentType.Orthogonal
861-
});
862-
}
863-
864-
// Create connector with calculated segments
779+
// Create connector with orthogonal routing
780+
// Don't specify segments - let Syncfusion calculate the path
781+
// Ports guide the routing direction
865782
var connector = new Connector()
866783
{
867784
ID = $"Connector_Q{question.Id}_O{optionId}_To_Group{branchToGroupId}",
@@ -870,7 +787,6 @@ private void CreateConnectorsWithWaypoints(Dictionary<int, double> groupPosition
870787
TargetID = $"GroupContainer{branchToGroupId}",
871788
TargetPortID = targetPortId,
872789
Type = ConnectorSegmentType.Orthogonal,
873-
Segments = segments,
874790
Constraints = ConnectorConstraints,
875791
Style = new ShapeStyle() { StrokeColor = targetGroupColor, StrokeWidth = 2 },
876792
TargetDecorator = new DecoratorSettings()

0 commit comments

Comments
 (0)