Use different type of links between certain ports


First off, I think I’m having the same question as has been solved in this topic, but it’s kind of dated, and didn’t really solve my problem.

I defined a node and link template

    //block template map
var templateMap = new go.Map("string", go.Node);
templateMap.add("", this.initNormalBlock());
templateMap.add("inboundgateway", this.initInboundGateway());
templateMap.add("outboundgateway", this.initOutboundGateway());
templateMap.add("start", this.initStartBlock());
templateMap.add("end", this.initEndBlock());
this.diagram.nodeTemplateMap = templateMap;

//links template map
var linkTemplateMap = new go.Map("string", go.Link);
linkTemplateMap.add("normallink", this.initNormalLink());
linkTemplateMap.add("backlink", this.initBackLink());
this.diagram.linkTemplateMap = linkTemplateMap;

FlowDiagram.TemplateMap = templateMap;

Each node has up to three access ports. When a link is drawn between the bottom ports of the nodes, I’d like to use the “BackLink” link template, otherwise I’d like to use the “NormalLink” template. I didn’t manage to use the GraphLinksModel.linkCategoryProperty in the correct way, so it seems. Should I be changing the category of the links when the LinkDrawn method is being called?

Any help regarding this topic would be much appreciated.

Yes. You’d want to use:

myDiagram.model.setCategoryForLinkData(linkData, category);

That was easy, thanks a lot!