diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index 0d5c5d569..713b2f8f6 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -86,32 +86,19 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err NodeSep: opts.NodeSep, }, } - isHorizontal := false switch g.Root.Attributes.Direction.Value { case "down": rootAttrs.rankdir = "TB" case "right": rootAttrs.rankdir = "LR" - isHorizontal = true case "left": rootAttrs.rankdir = "RL" - isHorizontal = true case "up": rootAttrs.rankdir = "BT" default: rootAttrs.rankdir = "TB" } - maxLabelSize := 0 - for _, edge := range g.Edges { - size := edge.LabelDimensions.Width - if !isHorizontal { - size = edge.LabelDimensions.Height - } - maxLabelSize = go2.Max(maxLabelSize, size) - } - rootAttrs.ranksep = go2.Max(100, maxLabelSize+40) - configJS := setGraphAttrs(rootAttrs) if _, err := vm.RunString(configJS); err != nil { return err diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json index 2eb8b7fa0..1cb25935c 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json @@ -9,7 +9,7 @@ "x": 0, "y": 0 }, - "width": 2628, + "width": 1583, "height": 237, "opacity": 1, "strokeDash": 0, @@ -46,7 +46,7 @@ "id": "build_workflow.push", "type": "", "pos": { - "x": 105, + "x": 0, "y": 50 }, "width": 330, @@ -86,7 +86,7 @@ "id": "build_workflow.GHA", "type": "", "pos": { - "x": 698, + "x": 384, "y": 50 }, "width": 269, @@ -126,7 +126,7 @@ "id": "build_workflow.S3", "type": "", "pos": { - "x": 1314, + "x": 791, "y": 50 }, "width": 131, @@ -166,7 +166,7 @@ "id": "build_workflow.Terraform", "type": "", "pos": { - "x": 1773, + "x": 1041, "y": 50 }, "width": 218, @@ -206,7 +206,7 @@ "id": "build_workflow.AWS", "type": "", "pos": { - "x": 2369, + "x": 1428, "y": 50 }, "width": 155, @@ -270,19 +270,19 @@ "labelPercentage": 0, "route": [ { - "x": 435.5, + "x": 330, "y": 118.5 }, { - "x": 539.9, + "x": 351.6, "y": 118.5 }, { - "x": 592.3, + "x": 362.4, "y": 118.5 }, { - "x": 697.5, + "x": 384, "y": 118.5 } ], @@ -318,19 +318,19 @@ "labelPercentage": 0, "route": [ { - "x": 966.5, + "x": 653, "y": 118.5 }, { - "x": 1105.3, + "x": 708.2, "y": 118.5 }, { - "x": 1174.7, + "x": 735.8, "y": 118.5 }, { - "x": 1313.5, + "x": 791, "y": 118.5 } ], @@ -366,19 +366,19 @@ "labelPercentage": 0, "route": [ { - "x": 1445.5, + "x": 922, "y": 118.5 }, { - "x": 1575.9, + "x": 969.6, "y": 118.5 }, { - "x": 1641.3, + "x": 993.5, "y": 118.5 }, { - "x": 1772.5, + "x": 1041.5, "y": 118.5 } ], @@ -414,19 +414,19 @@ "labelPercentage": 0, "route": [ { - "x": 1991.5, + "x": 1259, "y": 118.5 }, { - "x": 2141.9, + "x": 1326.6, "y": 118.5 }, { - "x": 2217.3, + "x": 1360.5, "y": 118.5 }, { - "x": 2368.5, + "x": 1428.5, "y": 118.5 } ], diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg index 1e7b73085..19b36bcab 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="2832" height="441" viewBox="-102 -102 2832 441">

Oldest message

+

Oldest message

Offset

Last message

Next message will be
inserted here

-
M0M1M2M3M4M5M6 - +
M0M1M2M3M4M5M6 + aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 - - - - - - - - - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + + + + + + + + + xyThe top of the mountainJoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

+xyThe top of the mountainJoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
i am top lefti am top righti am bottom lefti am bottom right - +
i am top lefti am top righti am bottom lefti am bottom right + poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

-
- +poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

+
+

Markdown: Syntax

+

Markdown: Syntax

  • Overview
      @@ -1053,8 +1053,8 @@ title for the link, surrounded in quotes. For example:

      Code

      Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

      -
ab - +
ab +

Note: This document is itself written using Markdown; you +

Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


Overview

-
ab - +
ab + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + +
    +
    • Overview
      • Philosophy
      • @@ -808,8 +808,8 @@ width="583" height="756" viewBox="-102 -102 583 756">
          +
          • Overview ok this is all measured
            • Philosophy
            • @@ -804,8 +804,8 @@ width="449" height="732" viewBox="-102 -102 449 732">
                +
                • Overview
                  • Philosophy
                  • @@ -829,8 +829,8 @@ width="551" height="1168" viewBox="-102 -102 551 1168">

                    List items may consist of multiple paragraphs. Each subsequent +

                    List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

                      @@ -827,8 +827,8 @@ sit amet, consectetuer adipiscing elit.

                      Another item in the same list.

                  -
                ab - +
              ab +

              Markdown: Syntax

              -
              ab - +

              Markdown: Syntax

              +
              ab +

              Every frustum longs to be a cone

              +

              Every frustum longs to be a cone

              • A continuing flow of paper is sufficient to continue the flow of paper
              • Please remain calm, it's no use both of us being hysterical at the same time
              • Visits always give pleasure: if not on arrival, then on the departure

              Festivity Level 1: Your guests are chatting amiably with each other.

              -
              xy - +
              xy + container

              they did it in style

              -

              a header

              +container

              they did it in style

              +

              a header

              a line of text and an

              {
               	indented: "block",
              @@ -805,8 +805,8 @@ width="516" height="685" viewBox="-102 -102 516 685">markdown

              Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              +markdown

              Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

              -
              - +
              + markdown

              Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              +markdown

              Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

              -
              - +
              +
              {
              +
              {
               	fenced: "block",
               	of: "json",
               }
               
              -
              ab - +
              ab +

              a line of text and an

              +

              a line of text and an

              {
               	indented: "block",
               	of: "json",
               }
               
              -
              ab - +
              ab +

              code

              -
              ab - +

              code

              +
              ab +

              A paragraph is simply one or more consecutive lines of text, separated +

              A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

              -
              ab - +
              ab +

              Here is an example of AppleScript:

              +

              Here is an example of AppleScript:

              tell application "Foo"
                   beep
               end tell
               

              A code block continues until it reaches a line that is not indented (or the end of the article).

              -
              ab - +
              ab + bearmama bearpapa bear - +bearmama bearpapa bear +