From 918ad5d96e03cbb2c3fd7e9bfeb9a16bff192afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Batista?= Date: Mon, 28 Nov 2022 13:08:52 -0800 Subject: [PATCH] constants --- d2layouts/d2sequence/constants.go | 4 ++-- d2layouts/d2sequence/layout.go | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/d2layouts/d2sequence/constants.go b/d2layouts/d2sequence/constants.go index 5004ea4d6..bdffd77f8 100644 --- a/d2layouts/d2sequence/constants.go +++ b/d2layouts/d2sequence/constants.go @@ -1,7 +1,7 @@ package d2sequence -// min horizontal pad for actors, or edge labels, to consider the min distance between them -const MIN_HORIZONTAL_PAD = 50. +// leaves at least 25 units of space on the left/right when computing the space required between actors +const HORIZONTAL_PAD = 50. const MIN_ACTOR_DISTANCE = 200. diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index ebe17b2ff..c98b5b3c4 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -12,16 +12,15 @@ import ( ) func Layout(ctx context.Context, g *d2graph.Graph) (err error) { - pad := MIN_HORIZONTAL_PAD edgeYStep := MIN_EDGE_DISTANCE actorXStep := MIN_ACTOR_DISTANCE maxActorHeight := 0. for _, edge := range g.Edges { - edgeYStep = math.Max(edgeYStep, float64(edge.LabelDimensions.Height)+pad) - actorXStep = math.Max(actorXStep, float64(edge.LabelDimensions.Width)+pad) - maxActorHeight = math.Max(maxActorHeight, edge.Src.Height+pad) - maxActorHeight = math.Max(maxActorHeight, edge.Dst.Height+pad) + edgeYStep = math.Max(edgeYStep, float64(edge.LabelDimensions.Height)+HORIZONTAL_PAD) + actorXStep = math.Max(actorXStep, float64(edge.LabelDimensions.Width)+HORIZONTAL_PAD) + maxActorHeight = math.Max(maxActorHeight, edge.Src.Height+HORIZONTAL_PAD) + maxActorHeight = math.Max(maxActorHeight, edge.Dst.Height+HORIZONTAL_PAD) } placeActors(g.Objects, maxActorHeight, actorXStep)