From ca754aefdc525b0afd26e17048ad39eb4972f0ac Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Oct 2023 14:49:09 -0700 Subject: [PATCH 1/5] add glob_dimensions test --- e2etests/regression_test.go | 1 + e2etests/testdata/files/glob_dimensions.d2 | 48 + .../glob_dimensions/dagre/board.exp.json | 935 ++++++++++++++++++ .../glob_dimensions/dagre/sketch.exp.svg | 124 +++ .../glob_dimensions/elk/board.exp.json | 829 ++++++++++++++++ .../glob_dimensions/elk/sketch.exp.svg | 124 +++ 6 files changed, 2061 insertions(+) create mode 100644 e2etests/testdata/files/glob_dimensions.d2 create mode 100644 e2etests/testdata/regression/glob_dimensions/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/glob_dimensions/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/glob_dimensions/elk/board.exp.json create mode 100644 e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index f6ad0d4db..211272caf 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -1049,6 +1049,7 @@ cf many required: { loadFromFile(t, "disclaimer"), loadFromFile(t, "grid_rows_gap_bug"), loadFromFile(t, "grid_image_label_position"), + loadFromFile(t, "glob_dimensions"), } runa(t, tcs) diff --git a/e2etests/testdata/files/glob_dimensions.d2 b/e2etests/testdata/files/glob_dimensions.d2 new file mode 100644 index 000000000..00a3984f9 --- /dev/null +++ b/e2etests/testdata/files/glob_dimensions.d2 @@ -0,0 +1,48 @@ +**: { + style.border-radius: 16 +} + +**: { + &label: end + label: ⬤ + shape: circle + height: 10 + width: 10 +} + +**: { + &label: start + label: ⬤ + label.near: center-center + style.fill: black + shape: circle + height: 10 + width: 10 +} + +**: { + &shape: diamond + label: "" + height: 20 + width: 20 +} + +start -> Check PIN + +Check PIN: { + direction: right + + start -> Enter PIN + choice.shape: diamond + + Enter PIN -> choice: "/check PIN" + choice -> Enter PIN: "[pin invalid]" + choice -> end: "[pin OK]" +} + +Check PIN -> Search Network: "[pin OK]" +Search Network -> Ready: network found + +Check PIN -> Off: power off +Search Network -> Off: power off +Ready -> Off: power off diff --git a/e2etests/testdata/regression/glob_dimensions/dagre/board.exp.json b/e2etests/testdata/regression/glob_dimensions/dagre/board.exp.json new file mode 100644 index 000000000..501f7c4fd --- /dev/null +++ b/e2etests/testdata/regression/glob_dimensions/dagre/board.exp.json @@ -0,0 +1,935 @@ +{ + "name": "", + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "start", + "type": "oval", + "pos": { + "x": 142, + "y": 0 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "black", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Check PIN", + "type": "rectangle", + "pos": { + "x": 18, + "y": 143 + }, + "width": 259, + "height": 534, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Check PIN", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 116, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Check PIN.start", + "type": "oval", + "pos": { + "x": 142, + "y": 173 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "black", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.Enter PIN", + "type": "rectangle", + "pos": { + "x": 98, + "y": 296 + }, + "width": 111, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Enter PIN", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.choice", + "type": "diamond", + "pos": { + "x": 143, + "y": 483 + }, + "width": 20, + "height": 20, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "N4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.end", + "type": "oval", + "pos": { + "x": 142, + "y": 624 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Search Network", + "type": "rectangle", + "pos": { + "x": 133, + "y": 818 + }, + "width": 159, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Search Network", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 114, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Ready", + "type": "rectangle", + "pos": { + "x": 227, + "y": 1005 + }, + "width": 89, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Ready", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 44, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Off", + "type": "rectangle", + "pos": { + "x": 119, + "y": 1192 + }, + "width": 68, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 23, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(start -> Check PIN)[0]", + "src": "start", + "srcArrow": "none", + "dst": "Check PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 153, + "y": 23 + }, + { + "x": 153, + "y": 63 + }, + { + "x": 153, + "y": 78.80000305175781 + }, + { + "x": 153, + "y": 102 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(start -> Enter PIN)[0]", + "src": "Check PIN.start", + "srcArrow": "none", + "dst": "Check PIN.Enter PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 153, + "y": 196 + }, + { + "x": 153, + "y": 236 + }, + { + "x": 153, + "y": 256 + }, + { + "x": 153, + "y": 296 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(Enter PIN -> choice)[0]", + "src": "Check PIN.Enter PIN", + "srcArrow": "none", + "dst": "Check PIN.choice", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "/check PIN", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 72, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 127.75, + "y": 361.5 + }, + { + "x": 90.1500015258789, + "y": 410.29998779296875 + }, + { + "x": 94.19999694824219, + "y": 435.6000061035156 + }, + { + "x": 148, + "y": 488 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(choice -> Enter PIN)[0]", + "src": "Check PIN.choice", + "srcArrow": "none", + "dst": "Check PIN.Enter PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin invalid]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 78, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 158, + "y": 488 + }, + { + "x": 200, + "y": 435.6000061035156 + }, + { + "x": 203.10000610351562, + "y": 410.29998779296875 + }, + { + "x": 173.5, + "y": 361.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(choice -> end)[0]", + "src": "Check PIN.choice", + "srcArrow": "none", + "dst": "Check PIN.end", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin OK]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 53, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 153, + "y": 503 + }, + { + "x": 153, + "y": 551.4000244140625 + }, + { + "x": 153, + "y": 575.5999755859375 + }, + { + "x": 153, + "y": 624 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Check PIN -> Search Network)[0]", + "src": "Check PIN", + "srcArrow": "none", + "dst": "Search Network", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin OK]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 53, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 212.75, + "y": 676.5 + }, + { + "x": 212.75, + "y": 741.2999877929688 + }, + { + "x": 212.75, + "y": 769.7000122070312 + }, + { + "x": 212.75, + "y": 818.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Search Network -> Ready)[0]", + "src": "Search Network", + "srcArrow": "none", + "dst": "Ready", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "network found", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 233.5, + "y": 883.5 + }, + { + "x": 263.8999938964844, + "y": 932.2999877929688 + }, + { + "x": 271.5, + "y": 956.7000122070312 + }, + { + "x": 271.5, + "y": 1005.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Check PIN -> Off)[0]", + "src": "Check PIN", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 67.75, + "y": 676.5 + }, + { + "x": 67.75, + "y": 741.2999877929688 + }, + { + "x": 67.75, + "y": 776.2000122070312 + }, + { + "x": 67.75, + "y": 804.25 + }, + { + "x": 67.75, + "y": 832.2999877929688 + }, + { + "x": 67.75, + "y": 869.7000122070312 + }, + { + "x": 67.75, + "y": 897.75 + }, + { + "x": 67.75, + "y": 925.7999877929688 + }, + { + "x": 67.75, + "y": 963.2000122070312 + }, + { + "x": 67.75, + "y": 991.25 + }, + { + "x": 67.75, + "y": 1019.2999877929688 + }, + { + "x": 78.75, + "y": 1143.699951171875 + }, + { + "x": 122.75, + "y": 1192.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Search Network -> Off)[0]", + "src": "Search Network", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 192, + "y": 883.5 + }, + { + "x": 161.60000610351562, + "y": 932.2999877929688 + }, + { + "x": 154, + "y": 963.2000122070312 + }, + { + "x": 154, + "y": 991.25 + }, + { + "x": 154, + "y": 1019.2999877929688 + }, + { + "x": 153.8000030517578, + "y": 1143.699951171875 + }, + { + "x": 153, + "y": 1192.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Ready -> Off)[0]", + "src": "Ready", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 271.5, + "y": 1070.5 + }, + { + "x": 271.5, + "y": 1119.300048828125 + }, + { + "x": 254.5, + "y": 1144.9000244140625 + }, + { + "x": 186.5, + "y": 1198.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/regression/glob_dimensions/dagre/sketch.exp.svg b/e2etests/testdata/regression/glob_dimensions/dagre/sketch.exp.svg new file mode 100644 index 000000000..0630a4835 --- /dev/null +++ b/e2etests/testdata/regression/glob_dimensions/dagre/sketch.exp.svg @@ -0,0 +1,124 @@ +Check PINSearch NetworkReadyOffEnter PIN /check PIN[pin invalid][pin OK][pin OK]network foundpower offpower offpower off + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json b/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json new file mode 100644 index 000000000..d4d4550a3 --- /dev/null +++ b/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json @@ -0,0 +1,829 @@ +{ + "name": "", + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "start", + "type": "oval", + "pos": { + "x": 157, + "y": 12 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "black", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Check PIN", + "type": "rectangle", + "pos": { + "x": 37, + "y": 105 + }, + "width": 262, + "height": 644, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Check PIN", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 116, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Check PIN.start", + "type": "oval", + "pos": { + "x": 155, + "y": 155 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "black", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.Enter PIN", + "type": "rectangle", + "pos": { + "x": 111, + "y": 248 + }, + "width": 111, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Enter PIN", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.choice", + "type": "diamond", + "pos": { + "x": 126, + "y": 495 + }, + "width": 80, + "height": 20, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "N4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 2 + }, + { + "id": "Check PIN.end", + "type": "oval", + "pos": { + "x": 155, + "y": 676 + }, + "width": 23, + "height": 23, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "⬤", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Search Network", + "type": "rectangle", + "pos": { + "x": 29, + "y": 920 + }, + "width": 159, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Search Network", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 114, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Ready", + "type": "rectangle", + "pos": { + "x": 15, + "y": 1157 + }, + "width": 89, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Ready", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 44, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Off", + "type": "rectangle", + "pos": { + "x": 95, + "y": 1394 + }, + "width": 120, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 16, + "fill": "B6", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 23, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(start -> Check PIN)[0]", + "src": "start", + "srcArrow": "none", + "dst": "Check PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 169, + "y": 35 + }, + { + "x": 168, + "y": 105 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(start -> Enter PIN)[0]", + "src": "Check PIN.start", + "srcArrow": "none", + "dst": "Check PIN.Enter PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 167, + "y": 178 + }, + { + "x": 166, + "y": 248 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(Enter PIN -> choice)[0]", + "src": "Check PIN.Enter PIN", + "srcArrow": "none", + "dst": "Check PIN.choice", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "/check PIN", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 72, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 123.5, + "y": 314 + }, + { + "x": 123.5, + "y": 455 + }, + { + "x": 153.16600036621094, + "y": 455 + }, + { + "x": 153, + "y": 498 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(choice -> Enter PIN)[0]", + "src": "Check PIN.choice", + "srcArrow": "none", + "dst": "Check PIN.Enter PIN", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin invalid]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 78, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 180, + "y": 498 + }, + { + "x": 179.83299255371094, + "y": 455 + }, + { + "x": 209.5, + "y": 455 + }, + { + "x": 209.5, + "y": 314 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "Check PIN.(choice -> end)[0]", + "src": "Check PIN.choice", + "srcArrow": "none", + "dst": "Check PIN.end", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin OK]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 53, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 167, + "y": 515 + }, + { + "x": 166, + "y": 676 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Check PIN -> Search Network)[0]", + "src": "Check PIN", + "srcArrow": "none", + "dst": "Search Network", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "[pin OK]", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 53, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 108.75, + "y": 749 + }, + { + "x": 108.75, + "y": 920 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Search Network -> Ready)[0]", + "src": "Search Network", + "srcArrow": "none", + "dst": "Ready", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "network found", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 60, + "y": 986 + }, + { + "x": 60, + "y": 1157 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Check PIN -> Off)[0]", + "src": "Check PIN", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 240.99899291992188, + "y": 749 + }, + { + "x": 240.99899291992188, + "y": 1354 + }, + { + "x": 185.25, + "y": 1354 + }, + { + "x": 185.25, + "y": 1394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Search Network -> Off)[0]", + "src": "Search Network", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 157.5, + "y": 986 + }, + { + "x": 157.5, + "y": 1394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(Ready -> Off)[0]", + "src": "Ready", + "srcArrow": "none", + "dst": "Off", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "power off", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 66, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 60, + "y": 1223 + }, + { + "x": 60, + "y": 1354 + }, + { + "x": 125.25, + "y": 1354 + }, + { + "x": 125.25, + "y": 1394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg b/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg new file mode 100644 index 000000000..01f6b7d1a --- /dev/null +++ b/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg @@ -0,0 +1,124 @@ +Check PINSearch NetworkReadyOffEnter PIN /check PIN[pin invalid][pin OK][pin OK]network foundpower offpower offpower off + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9ab1971d5499fecff178d028587db9c1efec9598 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Oct 2023 16:13:19 -0700 Subject: [PATCH 2/5] elk: don't grow node if there is a width/height input --- d2layouts/d2elklayout/layout.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 95bb3305c..9159bac9a 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -202,22 +202,24 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err } walk(g.Root, nil, func(obj, parent *d2graph.Object) { - incoming := 0. - outgoing := 0. - for _, e := range g.Edges { - if e.Src == obj { - outgoing++ + if obj.Attributes.WidthAttr == nil || obj.Attributes.HeightAttr == nil { + incoming := 0. + outgoing := 0. + for _, e := range g.Edges { + if e.Src == obj { + outgoing++ + } + if e.Dst == obj { + incoming++ + } } - if e.Dst == obj { - incoming++ - } - } - if incoming >= 2 || outgoing >= 2 { - switch g.Root.Direction.Value { - case "right", "left": - obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing) - default: - obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing) + if incoming >= 2 || outgoing >= 2 { + switch g.Root.Direction.Value { + case "right", "left": + obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing) + default: + obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing) + } } } From 6e6da743b3853aa2e522f1abf2816b4c9cf102ec Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Oct 2023 16:14:08 -0700 Subject: [PATCH 3/5] update test --- .../glob_dimensions/elk/board.exp.json | 20 +-- .../glob_dimensions/elk/sketch.exp.svg | 168 +++++++++--------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json b/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json index d4d4550a3..883b70d65 100644 --- a/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json +++ b/e2etests/testdata/regression/glob_dimensions/elk/board.exp.json @@ -171,10 +171,10 @@ "id": "Check PIN.choice", "type": "diamond", "pos": { - "x": 126, + "x": 156, "y": 495 }, - "width": 80, + "width": 20, "height": 20, "opacity": 1, "strokeDash": 0, @@ -482,11 +482,11 @@ "y": 455 }, { - "x": 153.16600036621094, + "x": 163.16600036621094, "y": 455 }, { - "x": 153, + "x": 163, "y": 498 } ], @@ -520,11 +520,11 @@ "labelPercentage": 0, "route": [ { - "x": 180, - "y": 498 + "x": 170, + "y": 499 }, { - "x": 179.83299255371094, + "x": 169.83299255371094, "y": 455 }, { @@ -566,11 +566,11 @@ "labelPercentage": 0, "route": [ { - "x": 167, - "y": 515 + "x": 166, + "y": 514 }, { - "x": 166, + "x": 167, "y": 676 } ], diff --git a/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg b/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg index 01f6b7d1a..d1618374e 100644 --- a/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/glob_dimensions/elk/sketch.exp.svg @@ -1,23 +1,23 @@ -Check PINSearch NetworkReadyOffEnter PIN /check PIN[pin invalid][pin OK][pin OK]network foundpower offpower offpower off + .d2-325191290 .fill-N1{fill:#0A0F25;} + .d2-325191290 .fill-N2{fill:#676C7E;} + .d2-325191290 .fill-N3{fill:#9499AB;} + .d2-325191290 .fill-N4{fill:#CFD2DD;} + .d2-325191290 .fill-N5{fill:#DEE1EB;} + .d2-325191290 .fill-N6{fill:#EEF1F8;} + .d2-325191290 .fill-N7{fill:#FFFFFF;} + .d2-325191290 .fill-B1{fill:#0D32B2;} + .d2-325191290 .fill-B2{fill:#0D32B2;} + .d2-325191290 .fill-B3{fill:#E3E9FD;} + .d2-325191290 .fill-B4{fill:#E3E9FD;} + .d2-325191290 .fill-B5{fill:#EDF0FD;} + .d2-325191290 .fill-B6{fill:#F7F8FE;} + .d2-325191290 .fill-AA2{fill:#4A6FF3;} + .d2-325191290 .fill-AA4{fill:#EDF0FD;} + .d2-325191290 .fill-AA5{fill:#F7F8FE;} + .d2-325191290 .fill-AB4{fill:#EDF0FD;} + .d2-325191290 .fill-AB5{fill:#F7F8FE;} + .d2-325191290 .stroke-N1{stroke:#0A0F25;} + .d2-325191290 .stroke-N2{stroke:#676C7E;} + .d2-325191290 .stroke-N3{stroke:#9499AB;} + .d2-325191290 .stroke-N4{stroke:#CFD2DD;} + .d2-325191290 .stroke-N5{stroke:#DEE1EB;} + .d2-325191290 .stroke-N6{stroke:#EEF1F8;} + .d2-325191290 .stroke-N7{stroke:#FFFFFF;} + .d2-325191290 .stroke-B1{stroke:#0D32B2;} + .d2-325191290 .stroke-B2{stroke:#0D32B2;} + .d2-325191290 .stroke-B3{stroke:#E3E9FD;} + .d2-325191290 .stroke-B4{stroke:#E3E9FD;} + .d2-325191290 .stroke-B5{stroke:#EDF0FD;} + .d2-325191290 .stroke-B6{stroke:#F7F8FE;} + .d2-325191290 .stroke-AA2{stroke:#4A6FF3;} + .d2-325191290 .stroke-AA4{stroke:#EDF0FD;} + .d2-325191290 .stroke-AA5{stroke:#F7F8FE;} + .d2-325191290 .stroke-AB4{stroke:#EDF0FD;} + .d2-325191290 .stroke-AB5{stroke:#F7F8FE;} + .d2-325191290 .background-color-N1{background-color:#0A0F25;} + .d2-325191290 .background-color-N2{background-color:#676C7E;} + .d2-325191290 .background-color-N3{background-color:#9499AB;} + .d2-325191290 .background-color-N4{background-color:#CFD2DD;} + .d2-325191290 .background-color-N5{background-color:#DEE1EB;} + .d2-325191290 .background-color-N6{background-color:#EEF1F8;} + .d2-325191290 .background-color-N7{background-color:#FFFFFF;} + .d2-325191290 .background-color-B1{background-color:#0D32B2;} + .d2-325191290 .background-color-B2{background-color:#0D32B2;} + .d2-325191290 .background-color-B3{background-color:#E3E9FD;} + .d2-325191290 .background-color-B4{background-color:#E3E9FD;} + .d2-325191290 .background-color-B5{background-color:#EDF0FD;} + .d2-325191290 .background-color-B6{background-color:#F7F8FE;} + .d2-325191290 .background-color-AA2{background-color:#4A6FF3;} + .d2-325191290 .background-color-AA4{background-color:#EDF0FD;} + .d2-325191290 .background-color-AA5{background-color:#F7F8FE;} + .d2-325191290 .background-color-AB4{background-color:#EDF0FD;} + .d2-325191290 .background-color-AB5{background-color:#F7F8FE;} + .d2-325191290 .color-N1{color:#0A0F25;} + .d2-325191290 .color-N2{color:#676C7E;} + .d2-325191290 .color-N3{color:#9499AB;} + .d2-325191290 .color-N4{color:#CFD2DD;} + .d2-325191290 .color-N5{color:#DEE1EB;} + .d2-325191290 .color-N6{color:#EEF1F8;} + .d2-325191290 .color-N7{color:#FFFFFF;} + .d2-325191290 .color-B1{color:#0D32B2;} + .d2-325191290 .color-B2{color:#0D32B2;} + .d2-325191290 .color-B3{color:#E3E9FD;} + .d2-325191290 .color-B4{color:#E3E9FD;} + .d2-325191290 .color-B5{color:#EDF0FD;} + .d2-325191290 .color-B6{color:#F7F8FE;} + .d2-325191290 .color-AA2{color:#4A6FF3;} + .d2-325191290 .color-AA4{color:#EDF0FD;} + .d2-325191290 .color-AA5{color:#F7F8FE;} + .d2-325191290 .color-AB4{color:#EDF0FD;} + .d2-325191290 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]>Check PINSearch NetworkReadyOffEnter PIN /check PIN[pin invalid][pin OK][pin OK]network foundpower offpower offpower off @@ -113,8 +113,8 @@ - - + + From 637048ad28a446f987eb7f78bb1bcc0a23a4c811 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Oct 2023 16:19:53 -0700 Subject: [PATCH 4/5] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index c8622b674..40dfd2879 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -12,3 +12,4 @@ - Grid layout now accounts for labels wider or taller than the shape and fixes default label positions for image grid cells. [#1670](https://github.com/terrastruct/d2/pull/1670) - Fixes a panic with a spread substitution in a glob map [#1643](https://github.com/terrastruct/d2/pull/1643) - Fixes use of `null` in `sql_table` constraints (ty @landmaj) [#1660](https://github.com/terrastruct/d2/pull/1660) +- Fixes elk growing shapes with width/height set [#1679](https://github.com/terrastruct/d2/pull/1679) From 40e8cc8530053217d093e73b823328e92581f8f2 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Oct 2023 16:21:41 -0700 Subject: [PATCH 5/5] cleanup --- d2layouts/d2elklayout/layout.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 9159bac9a..6fbe5268f 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -202,22 +202,24 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err } walk(g.Root, nil, func(obj, parent *d2graph.Object) { - if obj.Attributes.WidthAttr == nil || obj.Attributes.HeightAttr == nil { - incoming := 0. - outgoing := 0. - for _, e := range g.Edges { - if e.Src == obj { - outgoing++ - } - if e.Dst == obj { - incoming++ - } + incoming := 0. + outgoing := 0. + for _, e := range g.Edges { + if e.Src == obj { + outgoing++ } - if incoming >= 2 || outgoing >= 2 { - switch g.Root.Direction.Value { - case "right", "left": + if e.Dst == obj { + incoming++ + } + } + if incoming >= 2 || outgoing >= 2 { + switch g.Root.Direction.Value { + case "right", "left": + if obj.Attributes.HeightAttr == nil { obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing) - default: + } + default: + if obj.Attributes.WidthAttr == nil { obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing) } }