Implementation of Administrative Units/Position

Hi there!
For my Diagram I have the requirements to also add Administrative Units / Positions to my tree (German term is “Stabsstellen”). This specific person is still a child of a boss, but doesn’t belong on the same level as all other children as he holds a “special” position. This parameter is simply passed as Type 1 for normal child and Type 2 for special child.

In case of a Type 1 person it should simply be displayed as a normal child, in case of Type 2 it would need to look something like this:

In this example the 3 children would have an attribute Type 1, and the administrative unit Type 2.

Is it possible to achieve this kind of design where a node would have a different link from the root and be displayed on the side instead of on the same level with all other children?

Thanks a lot!

Yes, I suggest you start from this sample: [EDIT: now included as a regular sample]

That includes a customized TreeLayout, named SideTreeLayout, that has a method that you can modify to decide whether a Node represents an administrative assistant. The method that is there just looks for particular names but you can generalize that by looking for some property that you add to the data.

The SideTreeLayout is sufficiently general that such assistants can themselves have direct reports, as is demonstrated twice in that sample.

Worked like a charm! I implemented the example code you sent me and the result is nearly exactly as I wanted. There is just one small thing to iron out and I can’t seem to find where to tweek that value.

The blue node is the Assistant, if possible I would like it to stand a little bit further to the right, instead of immediatly starting attached to the link. Can that be done by simply changing a spacing parameter? If yes where? And what exactly do all the “alternateAngle”, “alternateAlignment” ecc. do in the example code you sent me?

Thanks a lot!

Yes, you can adapt the SideTreeLayout.assignTreeVertexValues method:

    . . .
    if (any) {
      v.alignment = go.TreeLayout.AlignmentBus;
      v.nodeSpacing = 123;  // this is what you want to set
    } else . . .

The TreeVertex.alignment assignment is necessary. But you can set many of the other TreeVertex properties that you like, including the TreeVertex.nodeSpacing property that will control the distance between the assistant node and the main vertical link.

Those alternate... properties only apply for certain kinds of TreeLayout, as determined by TreeLayout.treeStyle. Read the doc for

Works like a charm thank you!
That’s everything I needed, thanks again!