cleanup
This commit is contained in:
parent
6a837fa038
commit
ad44eff47a
1 changed files with 23 additions and 21 deletions
|
|
@ -123,15 +123,18 @@ func withoutGridDiagrams(ctx context.Context, g *d2graph.Graph, layout d2graph.L
|
||||||
if obj.LabelDimensions.Height != 0 {
|
if obj.LabelDimensions.Height != 0 {
|
||||||
labelHeight := float64(obj.LabelDimensions.Height) + 2*label.PADDING
|
labelHeight := float64(obj.LabelDimensions.Height) + 2*label.PADDING
|
||||||
|
|
||||||
{
|
|
||||||
// also check for grid cells with outside top labels
|
// also check for grid cells with outside top labels
|
||||||
|
// the first grid object is at the top (and always exists)
|
||||||
topY := gd.objects[0].TopLeft.Y
|
topY := gd.objects[0].TopLeft.Y
|
||||||
highestLabel := topY
|
highestLabel := topY
|
||||||
for _, o := range gd.objects {
|
for _, o := range gd.objects {
|
||||||
|
// we only want to compute label positions for objects at the top of the grid
|
||||||
if o.TopLeft.Y > topY {
|
if o.TopLeft.Y > topY {
|
||||||
if gd.rowDirected {
|
if gd.rowDirected {
|
||||||
|
// if the grid is rowDirected (row1, row2, etc) we can stop after finishing the first row
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
|
// otherwise we continue until the next column
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +151,6 @@ func withoutGridDiagrams(ctx context.Context, g *d2graph.Graph, layout d2graph.L
|
||||||
if highestLabel < topY {
|
if highestLabel < topY {
|
||||||
labelHeight += topY - highestLabel + 2*label.PADDING
|
labelHeight += topY - highestLabel + 2*label.PADDING
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if labelHeight > float64(verticalPadding) {
|
if labelHeight > float64(verticalPadding) {
|
||||||
// if the label doesn't fit within the padding, we need to add more
|
// if the label doesn't fit within the padding, we need to add more
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue