Prevent that duplicate links are shown

Continuing the discussion from BPMN Subprocess size problem in BPMN Example:

Were you thinking of fromLinkableDuplicates and fromLinkableDuplicates? These default to false and disallow duplicate links.

No. That is for linking when using ports. I’m using just plain from and to data properties. Is there any link for older documentation? I think I can find what I meant if I can take a look into older GoJS documentation.

You can find any old version (including all the documentation) by substituting the version number for “latest” in the URL.

Note that images in some older versions may not load, but everything else will.

This is what I want to avoid:

"linkDataArray": [ {"from":"1", "to":2, "category":"in", "points":[200,115,200,115,200,185,200,185]}, {"from":"1", "to":3, "category":"in", "points":[200,115,200,115,175,285,175,285]}, {"from":"1", "to":4, "category":"in", "points":[200,115,200,115,225,385,225,385]}, {"from":"1", "to":5, "category":"in", "points":[200,115,200,115,175,485,175,485]}, {"from":"6", "to":7, "category":"in", "points":[400,115,400,115,400,185,400,185]}, {"from":"6", "to":8, "category":"in", "points":[400,115,400,115,500,285,500,285]}, {"from":"6", "to":9, "category":"in", "points":[400,115,400,115,425,385,425,385]}, {"from":"6", "to":10, "category":"in", "points":[400,115,400,115,500,485,500,485]}, {"from":"6", "to":11, "category":"in", "points":[400,115,400,115,400,585,400,585]}, {"from":"6", "to":12, "category":"in", "points":[400,115,400,115,400,685,400,685]}, {"from":"13", "to":8, "category":"in", "points":[600,115,600,115,537.5,285,537.5,285]}, {"from":"13", "to":10, "category":"in", "points":[600,115,600,115,550,485,550,485]}, {"from":"2", "to":3, "category":"follows", "points":[200,215,200,215,225,285,225,285]}, {"from":"2", "to":7, "category":"precedes", "points":[275,205,275,205,325,205,325,205]}, {"from":"3", "to":4, "category":"follows", "points":[175,315,175,315,175,385,175,385]}, {"from":"4", "to":5, "category":"follows", "points":[175,415,175,415,175,485,175,485]}, {"from":"4", "to":10, "category":"precedes", "points":[225,415,225,415,450,485,450,485]}, {"from":"7", "to":8, "category":"follows", "points":[400,215,400,215,462.5,285,462.5,285]}, {"from":"8", "to":9, "category":"follows", "points":[475,315,475,315,445,385,445,385]}, {"from":"8", "to":10, "category":"follows", "points":[525,315,525,315,525,485,525,485]}, {"from":"9", "to":3, "category":"precedes", "points":[355,385,355,385,200,315,200,315]}, {"from":"9", "to":10, "category":"follows", "points":[400,415,400,415,475,485,475,485]}, {"from":"10", "to":11, "category":"follows", "points":[500,515,500,515,425,585,425,585]}, {"from":"11", "to":12, "category":"follows", "points":[400,615,400,615,437.5,685,437.5,685]}, {"from":"12", "to":5, "category":"precedes", "points":[355,685,355,685,175,515,175,515]}, {"from":"9", "to":3, "category":"follows", "temp":true, "points":[385,385,385,385,237.5,315,237.5,315]}, {"from":"2", "to":7, "category":"follows", "temp":true, "points":[275,195,275,195,325,195,325,195]}, {"from":"12", "to":5, "category":"follows", "temp":true, "points":[385,685,385,685,225,515,225,515]}

I’m using a model.addLinkData({
from: key,
to: links[j],
category: cat
});

to insert new link. Can GoJS prevent that duplicate link added this way be in model or not?

There isn’t any property to control that, you’ll have to manually look at the data and determine if its OK to add such a link or not.

So you’ll want to do something like:


// if you don't have references to the nodes:
var n = myDiagram.findNodeForKey(key);
var n2 = myDiagram.links[j]);

if (n.findLinksBetween(n2).count === 0) myDiagram.model.addLinkData...

// otherwise, don't add the link data

Ok thanks.