Fix rowCenter calculation in ELK

Co-authored-by: gavin-ts <85081687+gavin-ts@users.noreply.github.com>
This commit is contained in:
Michał Wieluński 2023-10-25 08:39:22 +02:00
parent 28c04bbcb2
commit b76eaa4433
No known key found for this signature in database

View file

@ -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: