From 4aaaf8dfa258dfc57386428653e5b075510bdad6 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 9 Feb 2023 19:49:53 -0800 Subject: [PATCH] elk --- d2layouts/d2elklayout/layout.go | 6 +- d2renderers/d2svg/d2svg.go | 8 +- .../dagre_broken_arrowhead/elk/board.exp.json | 68 +- .../dagre_broken_arrowhead/elk/sketch.exp.svg | 8 +- .../elk/board.exp.json | 56 +- .../elk/sketch.exp.svg | 14 +- .../dagre_special_ids/elk/board.exp.json | 16 +- .../dagre_special_ids/elk/sketch.exp.svg | 6 +- .../elk_alignment/elk/board.exp.json | 128 +-- .../elk_alignment/elk/sketch.exp.svg | 22 +- .../elk_loop_panic/elk/board.exp.json | 28 +- .../elk_loop_panic/elk/sketch.exp.svg | 6 +- .../regression/elk_order/elk/board.exp.json | 74 +- .../regression/elk_order/elk/sketch.exp.svg | 14 +- .../empty_sequence/elk/board.exp.json | 4 +- .../empty_sequence/elk/sketch.exp.svg | 6 +- .../regression/md_h1_li_li/elk/board.exp.json | 10 +- .../regression/md_h1_li_li/elk/sketch.exp.svg | 8 +- .../elk/board.exp.json | 10 +- .../elk/sketch.exp.svg | 10 +- .../opacity-on-label/elk/board.exp.json | 4 +- .../opacity-on-label/elk/sketch.exp.svg | 8 +- .../overlapping-edge-label/elk/board.exp.json | 98 +- .../overlapping-edge-label/elk/sketch.exp.svg | 14 +- .../elk/board.exp.json | 20 +- .../elk/sketch.exp.svg | 6 +- .../elk/board.exp.json | 10 +- .../elk/sketch.exp.svg | 28 +- .../testdata/sanity/1_to_2/elk/board.exp.json | 12 +- .../testdata/sanity/1_to_2/elk/sketch.exp.svg | 6 +- .../testdata/sanity/basic/elk/board.exp.json | 4 +- .../testdata/sanity/basic/elk/sketch.exp.svg | 6 +- .../sanity/child_to_child/elk/board.exp.json | 26 +- .../sanity/child_to_child/elk/sketch.exp.svg | 6 +- .../connection_label/elk/board.exp.json | 4 +- .../connection_label/elk/sketch.exp.svg | 8 +- .../stable/all_shapes/elk/board.exp.json | 56 +- .../stable/all_shapes/elk/sketch.exp.svg | 6 +- .../all_shapes_multiple/elk/board.exp.json | 56 +- .../all_shapes_multiple/elk/sketch.exp.svg | 6 +- .../all_shapes_shadow/elk/board.exp.json | 56 +- .../all_shapes_shadow/elk/sketch.exp.svg | 6 +- .../stable/animated/dagre/sketch.exp.svg | 2 +- .../stable/animated/elk/board.exp.json | 44 +- .../stable/animated/elk/sketch.exp.svg | 8 +- .../arrowhead_adjustment/elk/board.exp.json | 36 +- .../arrowhead_adjustment/elk/sketch.exp.svg | 6 +- .../arrowhead_labels/elk/board.exp.json | 4 +- .../arrowhead_labels/elk/sketch.exp.svg | 8 +- .../stable/binary_tree/elk/board.exp.json | 108 +-- .../stable/binary_tree/elk/sketch.exp.svg | 6 +- .../testdata/stable/chaos1/elk/board.exp.json | 32 +- .../testdata/stable/chaos1/elk/sketch.exp.svg | 10 +- .../testdata/stable/chaos2/elk/board.exp.json | 276 +++--- .../testdata/stable/chaos2/elk/sketch.exp.svg | 22 +- .../child_parent_edges/elk/board.exp.json | 56 +- .../child_parent_edges/elk/sketch.exp.svg | 6 +- .../circle_arrowhead/elk/board.exp.json | 8 +- .../circle_arrowhead/elk/sketch.exp.svg | 10 +- .../circular_dependency/elk/board.exp.json | 16 +- .../circular_dependency/elk/sketch.exp.svg | 6 +- .../stable/code_snippet/elk/board.exp.json | 10 +- .../stable/code_snippet/elk/sketch.exp.svg | 8 +- .../stable/complex-layers/elk/board.exp.json | 24 +- .../connected_container/elk/board.exp.json | 56 +- .../connected_container/elk/sketch.exp.svg | 6 +- .../constant_near_stress/elk/board.exp.json | 14 +- .../constant_near_stress/elk/sketch.exp.svg | 8 +- .../constant_near_title/elk/board.exp.json | 32 +- .../constant_near_title/elk/sketch.exp.svg | 8 +- .../stable/container_edges/elk/board.exp.json | 118 +-- .../stable/container_edges/elk/sketch.exp.svg | 6 +- .../crow_foot_arrowhead/dagre/sketch.exp.svg | 2 +- .../crow_foot_arrowhead/elk/board.exp.json | 28 +- .../crow_foot_arrowhead/elk/sketch.exp.svg | 6 +- .../testdata/stable/dense/elk/board.exp.json | 206 ++-- .../testdata/stable/dense/elk/sketch.exp.svg | 6 +- .../different_subgraphs/elk/board.exp.json | 200 ++-- .../different_subgraphs/elk/sketch.exp.svg | 6 +- .../stable/direction/elk/board.exp.json | 158 ++-- .../stable/direction/elk/sketch.exp.svg | 6 +- .../stable/font_colors/elk/board.exp.json | 4 +- .../stable/font_colors/elk/sketch.exp.svg | 8 +- .../stable/font_sizes/elk/board.exp.json | 12 +- .../stable/font_sizes/elk/sketch.exp.svg | 12 +- .../giant_markdown_test/elk/board.exp.json | 10 +- .../giant_markdown_test/elk/sketch.exp.svg | 8 +- .../testdata/stable/hr/elk/board.exp.json | 10 +- .../testdata/stable/hr/elk/sketch.exp.svg | 8 +- .../testdata/stable/images/elk/board.exp.json | 4 +- .../testdata/stable/images/elk/sketch.exp.svg | 6 +- .../stable/investigate/elk/board.exp.json | 444 ++++----- .../stable/investigate/elk/sketch.exp.svg | 18 +- .../stable/large_arch/elk/board.exp.json | 418 ++++----- .../stable/large_arch/elk/sketch.exp.svg | 6 +- .../testdata/stable/latex/elk/board.exp.json | 42 +- .../testdata/stable/latex/elk/sketch.exp.svg | 8 +- .../testdata/stable/li1/elk/board.exp.json | 10 +- .../testdata/stable/li1/elk/sketch.exp.svg | 8 +- .../testdata/stable/li2/elk/board.exp.json | 10 +- .../testdata/stable/li2/elk/sketch.exp.svg | 8 +- .../testdata/stable/li3/elk/board.exp.json | 10 +- .../testdata/stable/li3/elk/sketch.exp.svg | 8 +- .../testdata/stable/li4/elk/board.exp.json | 10 +- .../testdata/stable/li4/elk/sketch.exp.svg | 8 +- .../testdata/stable/links/elk/board.exp.json | 4 +- .../testdata/stable/links/elk/sketch.exp.svg | 10 +- .../stable/lone_h1/elk/board.exp.json | 10 +- .../stable/lone_h1/elk/sketch.exp.svg | 8 +- .../stable/markdown/elk/board.exp.json | 10 +- .../stable/markdown/elk/sketch.exp.svg | 8 +- .../markdown_stroke_fill/elk/board.exp.json | 20 +- .../markdown_stroke_fill/elk/sketch.exp.svg | 10 +- .../md_2space_newline/elk/board.exp.json | 8 +- .../md_2space_newline/elk/sketch.exp.svg | 8 +- .../md_backslash_newline/elk/board.exp.json | 8 +- .../md_backslash_newline/elk/sketch.exp.svg | 8 +- .../md_code_block_fenced/elk/board.exp.json | 10 +- .../md_code_block_fenced/elk/sketch.exp.svg | 8 +- .../md_code_block_indented/elk/board.exp.json | 10 +- .../md_code_block_indented/elk/sketch.exp.svg | 8 +- .../stable/md_code_inline/elk/board.exp.json | 10 +- .../stable/md_code_inline/elk/sketch.exp.svg | 8 +- .../stable/multiple_trees/elk/board.exp.json | 174 ++-- .../stable/multiple_trees/elk/sketch.exp.svg | 6 +- .../stable/n22_e32/elk/board.exp.json | 258 ++--- .../stable/n22_e32/elk/sketch.exp.svg | 6 +- .../number_connections/elk/board.exp.json | 8 +- .../number_connections/elk/sketch.exp.svg | 6 +- .../one_container_loop/elk/board.exp.json | 128 +-- .../one_container_loop/elk/sketch.exp.svg | 6 +- .../elk/board.exp.json | 130 +-- .../elk/sketch.exp.svg | 6 +- .../elk/board.exp.json | 162 ++-- .../elk/sketch.exp.svg | 18 +- e2etests/testdata/stable/p/elk/board.exp.json | 10 +- e2etests/testdata/stable/p/elk/sketch.exp.svg | 8 +- .../testdata/stable/pre/elk/board.exp.json | 10 +- .../testdata/stable/pre/elk/sketch.exp.svg | 8 +- .../self-referencing/elk/board.exp.json | 10 +- .../self-referencing/elk/sketch.exp.svg | 6 +- .../sequence_diagrams/elk/board.exp.json | 600 ++++++------ .../sequence_diagrams/elk/sketch.exp.svg | 54 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 10 +- .../stable/sql_tables/elk/board.exp.json | 16 +- .../stable/sql_tables/elk/sketch.exp.svg | 20 +- .../stable/square_3d/elk/board.exp.json | 4 +- .../stable/square_3d/elk/sketch.exp.svg | 10 +- .../elk/board.exp.json | 264 +++--- .../elk/sketch.exp.svg | 6 +- .../stable/stylish/elk/board.exp.json | 4 +- .../stable/stylish/elk/sketch.exp.svg | 12 +- .../stable/text_font_sizes/elk/board.exp.json | 10 +- .../stable/text_font_sizes/elk/sketch.exp.svg | 6 +- .../stable/tooltips/elk/board.exp.json | 4 +- .../stable/tooltips/elk/sketch.exp.svg | 8 +- .../unnamed_only_height/elk/board.exp.json | 22 +- .../unnamed_only_height/elk/sketch.exp.svg | 28 +- .../unnamed_only_width/elk/board.exp.json | 22 +- .../unnamed_only_width/elk/sketch.exp.svg | 28 +- .../testdata/stable/us_map/elk/board.exp.json | 888 +++++++++--------- .../testdata/stable/us_map/elk/sketch.exp.svg | 6 +- .../container_child_edge/elk/board.exp.json | 34 +- .../container_child_edge/elk/sketch.exp.svg | 10 +- .../elk/board.exp.json | 32 +- .../elk/sketch.exp.svg | 6 +- .../todo/font_sizes_large/elk/board.exp.json | 22 +- .../todo/font_sizes_large/elk/sketch.exp.svg | 14 +- .../shape_set_width_height/elk/board.exp.json | 132 +-- .../shape_set_width_height/elk/sketch.exp.svg | 56 +- .../todo/tall_edge_label/elk/board.exp.json | 4 +- .../todo/tall_edge_label/elk/sketch.exp.svg | 8 +- 174 files changed, 3545 insertions(+), 3537 deletions(-) diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 671fc2790..b4c6dd464 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -87,9 +87,9 @@ type ConfigurableOpts struct { var DefaultOpts = ConfigurableOpts{ Algorithm: "layered", - NodeSpacing: 100.0, - Padding: "[top=75,left=75,bottom=75,right=75]", - EdgeNodeSpacing: 50.0, + NodeSpacing: 60.0, + Padding: "[top=50,left=50,bottom=50,right=50]", + EdgeNodeSpacing: 40.0, SelfLoopSpacing: 50.0, } diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 546ec2740..2752d9a95 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -117,8 +117,8 @@ func arrowheadDimensions(arrowhead d2target.Arrowhead, strokeWidth float64) (wid widthMultiplier = 12 heightMultiplier = 12 case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired: - widthMultiplier = 14 - heightMultiplier = 15 + widthMultiplier = 11 + heightMultiplier = 12 } clippedStrokeWidth := go2.Max(MIN_ARROWHEAD_STROKE_WIDTH, strokeWidth) @@ -298,8 +298,8 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s attrs, modifier, width-3.0, height/2.0, width+offset, height/2.0, - offset*1.8, 0., - offset*1.8, height, + offset*1.6, 0., + offset*1.6, height, ) } default: diff --git a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json index 990e09636..d937d693c 100644 --- a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json @@ -9,8 +9,8 @@ "x": 12, "y": 12 }, - "width": 354, - "height": 701, + "width": 290, + "height": 541, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -47,8 +47,8 @@ "id": "a.b", "type": "rectangle", "pos": { - "x": 97, - "y": 87 + "x": 62, + "y": 62 }, "width": 53, "height": 66, @@ -88,11 +88,11 @@ "id": "a.c", "type": "rectangle", "pos": { - "x": 87, - "y": 422 + "x": 76, + "y": 337 }, - "width": 204, - "height": 216, + "width": 154, + "height": 166, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -129,8 +129,8 @@ "id": "a.1", "type": "rectangle", "pos": { - "x": 163, - "y": 256 + "x": 127, + "y": 191 }, "width": 52, "height": 66, @@ -170,8 +170,8 @@ "id": "a.2", "type": "rectangle", "pos": { - "x": 235, - "y": 256 + "x": 199, + "y": 191 }, "width": 53, "height": 66, @@ -211,8 +211,8 @@ "id": "a.c.d", "type": "rectangle", "pos": { - "x": 162, - "y": 497 + "x": 126, + "y": 387 }, "width": 54, "height": 66, @@ -276,20 +276,20 @@ "labelPercentage": 0, "route": [ { - "x": 124, - "y": 153 + "x": 88.5, + "y": 128 }, { - "x": 124, - "y": 372 + "x": 88.5, + "y": 297 }, { - "x": 138, - "y": 372 + "x": 115, + "y": 297 }, { - "x": 138, - "y": 422 + "x": 115, + "y": 337 } ], "animated": false, @@ -323,12 +323,12 @@ "labelPercentage": 0, "route": [ { - "x": 189, - "y": 322 + "x": 153.5, + "y": 257 }, { - "x": 189, - "y": 422 + "x": 153.5, + "y": 337 } ], "animated": false, @@ -362,20 +362,20 @@ "labelPercentage": 0, "route": [ { - "x": 261.5, - "y": 322 + "x": 226, + "y": 257 }, { - "x": 261.5, - "y": 372 + "x": 226, + "y": 297 }, { - "x": 240, - "y": 372 + "x": 192, + "y": 297 }, { - "x": 240, - "y": 422 + "x": 192, + "y": 337 } ], "animated": false, diff --git a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/sketch.exp.svg b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/sketch.exp.svg index 90c7a4d8a..2bb759d8c 100644 --- a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/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="558" height="905" viewBox="-90 -90 558 905">

Oldest message

-

Offset

-

Last message

-

Next message will be
+

Oldest message

+

Offset

+

Last message

+

Next message will be
inserted here

-
M0M1M2M3M4M5M6 - +
M0M1M2M3M4M5M6 +

hey

+

hey

  • they
      @@ -804,8 +804,8 @@ width="299" height="651" viewBox="-90 -90 299 651">x

      linux: because a PC is a terrible thing to waste

      -
      a You don't have to know how the computer works,just how to work the computer. - - +
a You don't have to know how the computer works,just how to work the computer. + + aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 - - - - - - - - - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + + + + + + + + + xyThe top of the mountain

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

+xyThe top of the mountain

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.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +
JoeDonaldi 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="636" viewBox="-90 -90 583 636">
          +
          • Overview ok this is all measured
            • Philosophy
            • @@ -804,8 +804,8 @@ width="449" height="612" viewBox="-90 -90 449 612">
                +
                • Overview
                  • Philosophy
                  • @@ -829,8 +829,8 @@ width="551" height="1048" viewBox="-90 -90 551 1048">

                    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="566" height="736" viewBox="-90 -90 566 736">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 + containerscloudtall cylinderclass- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidusersid -int -name -string -email -string -password -string -last_login -datetime -container

              markdown text expanded to 800x400

              -
              := 5 +containerscloudtall cylinderclass- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidusersid +int +name +string +email +string +password +string +last_login +datetime +container

              markdown text expanded to 800x400

              +
              := 5 := a + 7 -fmt.Printf("%d", b):= 5 +fmt.Printf("%d", b):= 5 := a + 7 -fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval - +
              fmt.Printf("%d", b)
              circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval +