fix root grid shift
This commit is contained in:
parent
a5dec20dd4
commit
593bea6982
2 changed files with 18 additions and 13 deletions
|
|
@ -188,19 +188,21 @@ func Layout2(ctx context.Context, g *d2graph.Graph) error {
|
||||||
|
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
|
|
||||||
horizontalPadding, verticalPadding := CONTAINER_PADDING, CONTAINER_PADDING
|
if g.RootLevel > 0 {
|
||||||
if obj.GridGap != nil || obj.HorizontalGap != nil {
|
horizontalPadding, verticalPadding := CONTAINER_PADDING, CONTAINER_PADDING
|
||||||
horizontalPadding = gd.horizontalGap
|
if obj.GridGap != nil || obj.HorizontalGap != nil {
|
||||||
}
|
horizontalPadding = gd.horizontalGap
|
||||||
if obj.GridGap != nil || obj.VerticalGap != nil {
|
}
|
||||||
verticalPadding = gd.verticalGap
|
if obj.GridGap != nil || obj.VerticalGap != nil {
|
||||||
}
|
verticalPadding = gd.verticalGap
|
||||||
|
}
|
||||||
|
|
||||||
// shift the grid from (0, 0)
|
// shift the grid from (0, 0)
|
||||||
gd.shift(
|
gd.shift(
|
||||||
obj.TopLeft.X+float64(horizontalPadding),
|
obj.TopLeft.X+float64(horizontalPadding),
|
||||||
obj.TopLeft.Y+float64(verticalPadding),
|
obj.TopLeft.Y+float64(verticalPadding),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,10 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co
|
||||||
for _, e := range nestedGraph.Edges {
|
for _, e := range nestedGraph.Edges {
|
||||||
e.Move(dx, dy)
|
e.Move(dx, dy)
|
||||||
}
|
}
|
||||||
} else if !gi.isDefault() {
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !gi.isDefault() {
|
||||||
// empty grid can have 0 objects..
|
// empty grid can have 0 objects..
|
||||||
if gi.DiagramType == GridDiagram && !gi.IsConstantNear && len(curr.Children) == 0 {
|
if gi.DiagramType == GridDiagram && !gi.IsConstantNear && len(curr.Children) == 0 {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue