From b76eaa44331895a4402c63a9c758993a7597872a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wielu=C5=84ski?= Date: Wed, 25 Oct 2023 08:39:22 +0200 Subject: [PATCH] Fix rowCenter calculation in ELK Co-authored-by: gavin-ts <85081687+gavin-ts@users.noreply.github.com> --- d2layouts/d2elklayout/layout.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index d9eab2212..3fb25014b 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -673,9 +673,11 @@ func deleteBends(g *d2graph.Graph) { // Make sure it's still attached switch { case columnIndex != nil: - maxRowOffset := endpoint.Height / float64(len(endpoint.SQLTable.Columns)+1) / 3 - rowCenter := endpoint.TopLeft.Y + maxRowOffset*float64(*columnIndex+1)*2 + maxRowOffset - if math.Abs(end.Y-rowCenter) > maxRowOffset { + rowHeight := endpoint.Height / float64(len(endpoint.SQLTable.Columns)+1) + rowCenter := endpoint.TopLeft.Y + rowHeight*float64(*columnIndex+1) + rowHeight/2 + + // for row connections new Y coordinate should be within 1/3 row height from the row center + if math.Abs(end.Y-rowCenter) > rowHeight/3 { continue } case isHorizontal: