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))
|
||||
|
||||
horizontalPadding, verticalPadding := CONTAINER_PADDING, CONTAINER_PADDING
|
||||
if obj.GridGap != nil || obj.HorizontalGap != nil {
|
||||
horizontalPadding = gd.horizontalGap
|
||||
}
|
||||
if obj.GridGap != nil || obj.VerticalGap != nil {
|
||||
verticalPadding = gd.verticalGap
|
||||
}
|
||||
if g.RootLevel > 0 {
|
||||
horizontalPadding, verticalPadding := CONTAINER_PADDING, CONTAINER_PADDING
|
||||
if obj.GridGap != nil || obj.HorizontalGap != nil {
|
||||
horizontalPadding = gd.horizontalGap
|
||||
}
|
||||
if obj.GridGap != nil || obj.VerticalGap != nil {
|
||||
verticalPadding = gd.verticalGap
|
||||
}
|
||||
|
||||
// shift the grid from (0, 0)
|
||||
gd.shift(
|
||||
obj.TopLeft.X+float64(horizontalPadding),
|
||||
obj.TopLeft.Y+float64(verticalPadding),
|
||||
)
|
||||
// shift the grid from (0, 0)
|
||||
gd.shift(
|
||||
obj.TopLeft.X+float64(horizontalPadding),
|
||||
obj.TopLeft.Y+float64(verticalPadding),
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,10 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co
|
|||
for _, e := range nestedGraph.Edges {
|
||||
e.Move(dx, dy)
|
||||
}
|
||||
} else if !gi.isDefault() {
|
||||
continue
|
||||
}
|
||||
|
||||
if !gi.isDefault() {
|
||||
// empty grid can have 0 objects..
|
||||
if gi.DiagramType == GridDiagram && !gi.IsConstantNear && len(curr.Children) == 0 {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue