Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

How to create a link that doesn't affect the layout?

$
0
0

@cfarmerlv wrote:

I have a LayeredDigraphLayout and I’m generally happy with its default look. I want to now add some links that are only conditionally visible and which do not affect the layout of the diagram at all. How can I do this? I have an example in a jsfiddle: https://jsfiddle.net/cfarmerga/43gmo81r/8/

let links = [ 
	{ from: 'one', to: 'two' },
  { from: 'two', to: 'three' },
  { from: 'two', to: 'four' },
  { from: 'three', to: 'five' },
  { from: 'four', to: 'six' },
  
  // I want the below link to not affect the layout at all.
  // I like the layout when it's commented-out, and I want to retain
  // the same node/link positions when this below link is present.
  { from: 'four', to: 'three', custom: true }	
];

let linkTemplate = $(go.Link, $(go.Shape, {
	},
	new go.Binding('isLayoutPositioned', '', data => !data.custom),
	new go.Binding('visible', '', data => !data.custom),
);

When I comment out the last link, in my example, the node layout is what I prefer. I want to include that last link and show it sometimes, but I just don’t want it to affect any existing positioning. I thought just setting isLayoutPositioned to false for this link would work, but apparently not. How can I include this link without having its presence move my nodes around?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles