Alternate arrangement with tree layout

i’m trying to have 2 different layouts w/in the same diagram, is this possible?

my current layout is:
myDiagram.layout =
GO(go.TreeLayout, {
treeStyle: go.TreeLayout.StyleLastParents,
arrangement: go.TreeLayout.ArrangementVertical,//ArrangementHorizontal,
// properties for most of the tree:
angle: 90,
layerSpacing: 50,
// properties for the “last parents”:
alternateAngle: 90,
alternateLayerSpacing: 50,
alternateNodeSpacing: 35 }
);

i would like to have the last 2 levels expand out in a vertical manner instead of horizontally as they do now.

is this possible? if so, how?

thanks for the help in advance.

-Phil

You are currently using TreeLayout style of StyleLastParents, so if you set alternateAngle: 0 the last subtrees would go towards the right instead of downwards (the main part of the tree will go downwards because angle: 90).

But if you want the last two layers of any subtree to go towards the right, you can override TreeLayout.assignTreeVertexValues to set angle = zero on the last parent vertexes and their parents. The documentation includes an example override via subclassing.

Assuming you are only setting the Diagram.layout (so that your customized TreeLayout does not need to be implemented as a subclass so that it can be copied properly), perhaps after setting myDiagram.layout you could do something like:

myDiagram.layout.assignTreeVertexValues = function(v) {
v.angle = (v.maxGenerationCount <= 2) ? 0 : 90;
};

Since this override sets TreeVertex.angle for all vertexes, it will take precedence over the values of TreeLayout.angle and TreeLayout.alternateAngle.

walter, thanks for the help.

this works, kind of for my situation.
if the entire tree is expanded it works, but what i’m looking for is to have the last 2 lowest levels of the entire diagram in a vertical manner.
the solution above does this for the last 2 subtrees (which if a subtree only has levels of 4 and the diagram has 7, this would make the subtree that has 4 expand vertically which is incorrect for what i need)

could setting the layout.assignTreeVertexValues be changed for nodes that meet a defined criteria? if it could, how? i’m thinking this may be the only way as that i could assign the treeVertexValues function for nodes that meet level 5 & 6 for example.

-Phil

TreeVertex.level

I just hope that that property has been computed by the time assignTreeVertexValues is called. If not, you’ll need to compute it yourself.