I want to rearrange links which has connected to object on GOJS Canvas/Diagram. For this I have used object.invalidateConnectedLinks() method. It rearranges links but while saving I am not able to find modified points in LayoutComplted event.
OR
I observe that while moving object, its links getting automatically rearrange. Is there any way to explicitly hook that event which rearrange connected link?
Or maybe you just want to establish a TwoWay Binding on the Link.points property:
$(go.Link,
new go.Binding("points").makeTwoWay(),
. . .)
Assuming you are using a GraphLinksModel, that will automatically update the link.data.points property to be an array of Points corresponding to the latest route for the link, in document coordinates.
I have already establish a TwoWay Binding in template.
There are two objects with multiple links “From” and “To” direction. Some links are overlapped on each other. I just want to avoid overlapping links, it should display arranged(like Screen 2).
Whenever adding any link between both objects, It seems like below screen (links not properly arranged).
if I select Object 1 and slightly moved(change location), the connection getting re-arranged automatically.
I want this functionality to re-arrange links on every time while adding new link between two Objects.
Currently it is not properly arranged and overlapped on each other.
I am not able to find out the way to arrange links while/after creating new link.
Thanks for the explanation – I was completely misunderstanding your problem.
Try defining this function:
function invalidateLinks(node, link, port) {
var from = link.fromNode;
if (from !== null) from.invalidateConnectedLinks();
var to = link.toNode;
if (to !== null) to.invalidateConnectedLinks();
}
and then add these two properties on your Node template: