consider root level of extracted subgraph
This commit is contained in:
parent
fab9f79039
commit
3e08f51c66
2 changed files with 5 additions and 1 deletions
|
|
@ -57,6 +57,9 @@ type Graph struct {
|
|||
Steps []*Graph `json:"steps,omitempty"`
|
||||
|
||||
Theme *d2themes.Theme `json:"theme,omitempty"`
|
||||
|
||||
// Object.Level uses the location of a nested graph
|
||||
RootLevel int `json:"rootLevel,omitempty"`
|
||||
}
|
||||
|
||||
func NewGraph() *Graph {
|
||||
|
|
@ -529,7 +532,7 @@ func (obj *Object) GetStroke(dashGapSize interface{}) string {
|
|||
|
||||
func (obj *Object) Level() ContainerLevel {
|
||||
if obj.Parent == nil {
|
||||
return 0
|
||||
return ContainerLevel(obj.Graph.RootLevel)
|
||||
}
|
||||
return 1 + obj.Parent.Level()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ func (g *Graph) ExtractAsNestedGraph(obj *Object) *Graph {
|
|||
descendantObjects, edges := pluckObjAndEdges(g, obj)
|
||||
|
||||
tempGraph := NewGraph()
|
||||
tempGraph.RootLevel = int(obj.Level()) - 1
|
||||
tempGraph.Root.ChildrenArray = []*Object{obj}
|
||||
tempGraph.Root.Children[strings.ToLower(obj.ID)] = obj
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue