This commit is contained in:
Gavin Nishizawa 2023-06-08 13:02:34 -07:00
parent 2261a0d0fc
commit 70cbe99302
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -787,7 +787,7 @@ func (gd *gridDiagram) fastLayout(targetSize float64, nCuts int, columns bool) (
} }
if rowSize == 0 { if rowSize == 0 {
if size > targetSize-debt { if size > targetSize-debt {
fastDivision = append(fastDivision, i-1) fastDivision = append(fastDivision, i)
// we build up a debt of distance past the target size across rows // we build up a debt of distance past the target size across rows
newDebt := size - targetSize newDebt := size - targetSize
debt += newDebt debt += newDebt
@ -916,6 +916,13 @@ func getDistToTarget(layout [][]*d2graph.Object, targetSize float64, horizontalG
rowSize += o.Width + horizontalGap rowSize += o.Width + horizontalGap
} }
} }
if len(row) > 0 {
if columns {
rowSize -= verticalGap
} else {
rowSize -= horizontalGap
}
}
totalDelta += math.Abs(rowSize - targetSize) totalDelta += math.Abs(rowSize - targetSize)
} }
return totalDelta return totalDelta