diff --git a/d2layouts/d2sequence/constants.go b/d2layouts/d2sequence/constants.go index 232109345..efd2d52db 100644 --- a/d2layouts/d2sequence/constants.go +++ b/d2layouts/d2sequence/constants.go @@ -14,9 +14,6 @@ const MIN_MESSAGE_DISTANCE = 100. // default size const SPAN_WIDTH = 20. -// small pad so that messages don't touch lifelines and spans -const SPAN_MESSAGE_PAD = 5. - // as the spans start getting nested, their size grows const SPAN_DEPTH_GROW_FACTOR = 10. diff --git a/d2layouts/d2sequence/layout_test.go b/d2layouts/d2sequence/layout_test.go index cd8974922..226584a45 100644 --- a/d2layouts/d2sequence/layout_test.go +++ b/d2layouts/d2sequence/layout_test.go @@ -108,19 +108,19 @@ func TestBasicSequenceDiagram(t *testing.T) { } if edge.Src.TopLeft.X < edge.Dst.TopLeft.X { // left to right - if edge.Route[0].X != edge.Src.Center().X+SPAN_MESSAGE_PAD { + if edge.Route[0].X != edge.Src.Center().X { t.Fatalf("expected edge[%d] x to be at the actor center", i) } - if edge.Route[1].X != edge.Dst.Center().X-SPAN_MESSAGE_PAD { + if edge.Route[1].X != edge.Dst.Center().X { t.Fatalf("expected edge[%d] x to be at the actor center", i) } } else { - if edge.Route[0].X != edge.Src.Center().X-SPAN_MESSAGE_PAD { + if edge.Route[0].X != edge.Src.Center().X { t.Fatalf("expected edge[%d] x to be at the actor center", i) } - if edge.Route[1].X != edge.Dst.Center().X+SPAN_MESSAGE_PAD { + if edge.Route[1].X != edge.Dst.Center().X { t.Fatalf("expected edge[%d] x to be at the actor center", i) } } @@ -246,7 +246,7 @@ func TestSpansSequenceDiagram(t *testing.T) { } // Y diff of the 2 first edges - expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + (2 * SPAN_MESSAGE_PAD) + expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y if a_t1.Height != expectedHeight { t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height) } @@ -268,20 +268,20 @@ func TestSpansSequenceDiagram(t *testing.T) { if a_t1.TopLeft.Y != b_t1.TopLeft.Y { t.Fatal("expected a.t1 and b.t1 to be placed at the same Y") } - if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y-SPAN_MESSAGE_PAD { + if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y { t.Fatal("expected a.t1 to be placed at the same Y of the first message") } // check routes - if g.Edges[0].Route[0].X != a_t1.TopLeft.X+a_t1.Width+SPAN_MESSAGE_PAD { + if g.Edges[0].Route[0].X != a_t1.TopLeft.X+a_t1.Width { t.Fatal("expected the first message to start on a.t1 top right X") } - if g.Edges[0].Route[1].X != b_t1.TopLeft.X-SPAN_MESSAGE_PAD { + if g.Edges[0].Route[1].X != b_t1.TopLeft.X { t.Fatal("expected the first message to end on b.t1 top left X") } - if g.Edges[2].Route[1].X != b.Center().X-SPAN_MESSAGE_PAD { + if g.Edges[2].Route[1].X != b.Center().X { t.Fatal("expected the third message to end on b.t1 center X") } } diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 9d70eb837..5664cb1db 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -202,14 +202,10 @@ func (sd *sequenceDiagram) placeSpans() { minY := math.Min(minMessageY, minChildY) if minY == minChildY { minY -= SPAN_DEPTH_GROW_FACTOR - } else { - minY -= SPAN_MESSAGE_PAD } maxY := math.Max(maxMessageY, maxChildY) if maxY == maxChildY { maxY += SPAN_DEPTH_GROW_FACTOR - } else { - maxY += SPAN_MESSAGE_PAD } height := math.Max(maxY-minY, MIN_SPAN_HEIGHT) @@ -245,14 +241,6 @@ func (sd *sequenceDiagram) routeMessages() { endX = message.Dst.TopLeft.X + message.Dst.Width } - if isLeftToRight { - startX += SPAN_MESSAGE_PAD - endX -= SPAN_MESSAGE_PAD - } else { - startX -= SPAN_MESSAGE_PAD - endX += SPAN_MESSAGE_PAD - } - messageY := sd.getMessageY(rank) message.Route = []*geo.Point{ geo.NewPoint(startX, messageY),