From 052faecbbdfa8fcbfdbbce60d108b228c660736f Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 4 Mar 2025 14:18:58 -0700 Subject: [PATCH 1/2] adjust legend positions --- d2compiler/compile.go | 6 ++--- .../d2compiler/TestCompile/legend.exp.json | 24 +++++++++---------- .../TestExport/legend/basic_legend.exp.json | 20 ++++++++-------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 179797803d..1ebb396cde 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -137,14 +137,14 @@ func (c *compiler) compileLegend(g *d2graph.Graph, m *d2ir.Map) { } } obj.Box = &geo.Box{} - obj.TopLeft = geo.NewPoint(0, 0) + obj.TopLeft = geo.NewPoint(10, 10) objects = append(objects, obj) } for _, edge := range legendGraph.Edges { edge.Route = []*geo.Point{ - {X: 0, Y: 0}, - {X: 0, Y: 0}, + {X: 10, Y: 10}, + {X: 110, Y: 10}, } } diff --git a/testdata/d2compiler/TestCompile/legend.exp.json b/testdata/d2compiler/TestCompile/legend.exp.json index 55e146b03d..80b5662794 100644 --- a/testdata/d2compiler/TestCompile/legend.exp.json +++ b/testdata/d2compiler/TestCompile/legend.exp.json @@ -816,8 +816,8 @@ ], "box": { "TopLeft": { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, "Width": 0, "Height": 0 @@ -913,8 +913,8 @@ ], "box": { "TopLeft": { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, "Width": 0, "Height": 0 @@ -950,12 +950,12 @@ "isCurve": false, "route": [ { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, { - "x": 0, - "y": 0 + "x": 110, + "y": 10 } ], "src_arrow": false, @@ -994,12 +994,12 @@ "isCurve": false, "route": [ { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, { - "x": 0, - "y": 0 + "x": 110, + "y": 10 } ], "src_arrow": false, diff --git a/testdata/d2exporter/TestExport/legend/basic_legend.exp.json b/testdata/d2exporter/TestExport/legend/basic_legend.exp.json index 720d46a313..a453bac391 100644 --- a/testdata/d2exporter/TestExport/legend/basic_legend.exp.json +++ b/testdata/d2exporter/TestExport/legend/basic_legend.exp.json @@ -166,8 +166,8 @@ "id": "legend", "type": "rectangle", "pos": { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, "width": 0, "height": 0, @@ -207,8 +207,8 @@ "id": "legend.l1", "type": "rectangle", "pos": { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, "width": 0, "height": 0, @@ -248,8 +248,8 @@ "id": "legend.l2", "type": "oval", "pos": { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, "width": 0, "height": 0, @@ -313,12 +313,12 @@ "link": "", "route": [ { - "x": 0, - "y": 0 + "x": 10, + "y": 10 }, { - "x": 0, - "y": 0 + "x": 110, + "y": 10 } ], "animated": false, From 61b90ece77b4ef988566fcaa03ea1c18e79ce92a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 4 Mar 2025 14:21:33 -0700 Subject: [PATCH 2/2] ta --- d2compiler/compile.go | 2 ++ testdata/d2compiler/TestCompile/legend.exp.json | 8 ++++---- .../TestExport/legend/basic_legend.exp.json | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 1ebb396cde..97f55f4a15 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -138,6 +138,8 @@ func (c *compiler) compileLegend(g *d2graph.Graph, m *d2ir.Map) { } obj.Box = &geo.Box{} obj.TopLeft = geo.NewPoint(10, 10) + obj.Width = 100 + obj.Height = 100 objects = append(objects, obj) } diff --git a/testdata/d2compiler/TestCompile/legend.exp.json b/testdata/d2compiler/TestCompile/legend.exp.json index 80b5662794..07e51deca5 100644 --- a/testdata/d2compiler/TestCompile/legend.exp.json +++ b/testdata/d2compiler/TestCompile/legend.exp.json @@ -819,8 +819,8 @@ "x": 10, "y": 10 }, - "Width": 0, - "Height": 0 + "Width": 100, + "Height": 100 }, "attributes": { "label": { @@ -916,8 +916,8 @@ "x": 10, "y": 10 }, - "Width": 0, - "Height": 0 + "Width": 100, + "Height": 100 }, "attributes": { "label": { diff --git a/testdata/d2exporter/TestExport/legend/basic_legend.exp.json b/testdata/d2exporter/TestExport/legend/basic_legend.exp.json index a453bac391..3790d88000 100644 --- a/testdata/d2exporter/TestExport/legend/basic_legend.exp.json +++ b/testdata/d2exporter/TestExport/legend/basic_legend.exp.json @@ -169,8 +169,8 @@ "x": 10, "y": 10 }, - "width": 0, - "height": 0, + "width": 100, + "height": 100, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -210,8 +210,8 @@ "x": 10, "y": 10 }, - "width": 0, - "height": 0, + "width": 100, + "height": 100, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -251,8 +251,8 @@ "x": 10, "y": 10 }, - "width": 0, - "height": 0, + "width": 100, + "height": 100, "opacity": 1, "strokeDash": 0, "strokeWidth": 2,