From 69385e016fff7eeb145067a4e8c0a1ac6fd82f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Batista?= Date: Mon, 5 Dec 2022 13:43:05 -0800 Subject: [PATCH] Fix actor padding for long notes --- d2layouts/d2sequence/sequence_diagram.go | 3 + .../dagre/board.exp.json | 70 +++++++++---------- .../dagre/sketch.exp.svg | 4 +- .../elk/board.exp.json | 70 +++++++++---------- .../elk/sketch.exp.svg | 4 +- 5 files changed, 77 insertions(+), 74 deletions(-) diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index feedea323..6f9eb67d1 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -142,6 +142,9 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se nextActorHW := actors[rank+1].Width / 2. sd.actorXStep[rank] = math.Max(actorHW+nextActorHW+HORIZONTAL_PAD, MIN_ACTOR_DISTANCE) sd.actorXStep[rank] = math.Max(maxNoteWidth/2.+HORIZONTAL_PAD, sd.actorXStep[rank]) + if rank > 0 { + sd.actorXStep[rank-1] = math.Max(maxNoteWidth/2.+HORIZONTAL_PAD, sd.actorXStep[rank-1]) + } } } diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json index fee70ce79..29b31ec66 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json @@ -8,7 +8,7 @@ "x": -121, "y": 266 }, - "width": 592, + "width": 655, "height": 952, "opacity": 1, "strokeDash": 0, @@ -47,7 +47,7 @@ "x": -97, "y": 396 }, - "width": 544, + "width": 607, "height": 798, "opacity": 1, "strokeDash": 0, @@ -86,7 +86,7 @@ "x": -73, "y": 526 }, - "width": 496, + "width": 559, "height": 644, "opacity": 1, "strokeDash": 0, @@ -125,7 +125,7 @@ "x": -49, "y": 656 }, - "width": 448, + "width": 511, "height": 490, "opacity": 1, "strokeDash": 0, @@ -244,7 +244,7 @@ "x": 25, "y": 1042 }, - "width": 350, + "width": 413, "height": 80, "opacity": 1, "strokeDash": 0, @@ -280,10 +280,10 @@ "id": "alt", "type": "", "pos": { - "x": 251, + "x": 314, "y": 1148 }, - "width": 461, + "width": 460, "height": 518, "opacity": 1, "strokeDash": 0, @@ -319,10 +319,10 @@ "id": "alt.case 1", "type": "", "pos": { - "x": 275, + "x": 338, "y": 1172 }, - "width": 413, + "width": 412, "height": 80, "opacity": 1, "strokeDash": 0, @@ -358,10 +358,10 @@ "id": "alt.case 2", "type": "", "pos": { - "x": 275, + "x": 338, "y": 1302 }, - "width": 413, + "width": 412, "height": 80, "opacity": 1, "strokeDash": 0, @@ -397,10 +397,10 @@ "id": "alt.case 3", "type": "", "pos": { - "x": 275, + "x": 338, "y": 1432 }, - "width": 413, + "width": 412, "height": 80, "opacity": 1, "strokeDash": 0, @@ -436,10 +436,10 @@ "id": "alt.case 4", "type": "", "pos": { - "x": 275, + "x": 338, "y": 1562 }, - "width": 413, + "width": 412, "height": 80, "opacity": 1, "strokeDash": 0, @@ -475,7 +475,7 @@ "id": "b", "type": "", "pos": { - "x": 250, + "x": 313, "y": 50 }, "width": 150, @@ -515,7 +515,7 @@ "id": "b.note", "type": "rectangle", "pos": { - "x": 62, + "x": 125, "y": 2052 }, "width": 525, @@ -595,7 +595,7 @@ "id": "c", "type": "", "pos": { - "x": 543, + "x": 605, "y": 50 }, "width": 190, @@ -663,7 +663,7 @@ "y": 306 }, { - "x": 325, + "x": 388, "y": 306 } ], @@ -702,7 +702,7 @@ "y": 436 }, { - "x": 325, + "x": 388, "y": 436 } ], @@ -741,7 +741,7 @@ "y": 566 }, { - "x": 325, + "x": 388, "y": 566 } ], @@ -780,7 +780,7 @@ "y": 952 }, { - "x": 325, + "x": 388, "y": 952 } ], @@ -819,7 +819,7 @@ "y": 1082 }, { - "x": 325, + "x": 388, "y": 1082 } ], @@ -854,11 +854,11 @@ "labelPercentage": 0, "route": [ { - "x": 325, + "x": 388, "y": 1212 }, { - "x": 638, + "x": 700, "y": 1212 } ], @@ -893,11 +893,11 @@ "labelPercentage": 0, "route": [ { - "x": 325, + "x": 388, "y": 1342 }, { - "x": 638, + "x": 700, "y": 1342 } ], @@ -932,11 +932,11 @@ "labelPercentage": 0, "route": [ { - "x": 325, + "x": 388, "y": 1472 }, { - "x": 638, + "x": 700, "y": 1472 } ], @@ -971,11 +971,11 @@ "labelPercentage": 0, "route": [ { - "x": 325, + "x": 388, "y": 1602 }, { - "x": 638, + "x": 700, "y": 1602 } ], @@ -1049,11 +1049,11 @@ "labelPercentage": 0, "route": [ { - "x": 325, + "x": 388, "y": 176 }, { - "x": 325, + "x": 388, "y": 2308 } ], @@ -1088,11 +1088,11 @@ "labelPercentage": 0, "route": [ { - "x": 638, + "x": 700, "y": 176 }, { - "x": 638, + "x": 700, "y": 2308 } ], diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg index d5d231a05..001eaaf1f 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg @@ -2,7 +2,7 @@