How to add new Links without any change in the diagram layout

Hi Team,

Currently, I have a diagram, it renders as I expect. Now I want to click a button to add some special links between nodes but I do not want the diagram layout to change, you can see the attachment belows.


Layout being used is LayeredDigraphLayout.

Here is my layout settings:
let settings = {
initialContentAlignment: go.Spot.Top,
initialAutoScale: go.Diagram.UniformToFill,
scrollMode: go.Diagram.DocumentScroll,
padding: new go.Margin(45, 30, 90, 30),
layout: $(go.LayeredDigraphLayout, {
direction: 90,
columnSpacing: 15,
layerSpacing: 5,
cycleRemoveOption: go.LayeredDigraphLayout.InitDepthFirstOut,
setsPortSpots: !this.boxesAndArrowMode
}),

Could any option be “link” but not Link can draw a line to connect two nodes? It can go straight on top of the nodes.

Please let me know what additional information you need.

Many thanks.

How do you determine whether a link should affect the layout or not?

One way is to set (on a different template) or bind the Part.isLayoutPositioned property. For example, see the colored links in the sample Org Chart Extras, Org Chart Extras. (It uses TreeLayout instead of LayeredDigraphLayout, but that doesn’t matter for this issue.)

That sample uses different Link templates, but you can use the same template if you data bind that Part.isLayoutPositioned property to false for those non-layout links.

1 Like