diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index 85ef8ff72..057ca405a 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -152,5 +152,14 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) { } } + if math.IsInf(x1, 1) && math.IsInf(x2, -1) { + x1 = 0 + x2 = 0 + } + if math.IsInf(y1, 1) && math.IsInf(y2, -1) { + y1 = 0 + y2 = 0 + } + return geo.NewPoint(x1, y1), geo.NewPoint(x2, y2) } diff --git a/e2etests/testdata/stable/near-alone/dagre/board.exp.json b/e2etests/testdata/stable/near-alone/dagre/board.exp.json index dba43ee30..1ab5233e0 100644 --- a/e2etests/testdata/stable/near-alone/dagre/board.exp.json +++ b/e2etests/testdata/stable/near-alone/dagre/board.exp.json @@ -87,7 +87,7 @@ "type": "", "pos": { "x": -189, - "y": 0 + "y": -63 }, "width": 112, "height": 126, diff --git a/e2etests/testdata/stable/near-alone/dagre/sketch.exp.svg b/e2etests/testdata/stable/near-alone/dagre/sketch.exp.svg index 3944c699c..fbd9d0187 100644 --- a/e2etests/testdata/stable/near-alone/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/near-alone/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="450" height="496" viewBox="-291 -248 450 496">