Link Template Mapping (routing) not working

Hi Walter,

I have followed the steps in the below example under the Routing:
https://gojs.net/latest/intro/links.html

this.surfaceNetworkIntegrationSrv.GetEquipments(this.snmService.selectedModel.Id, subsheetId, selectedScenrioId)
.finally(() =>
{
this.ngBlockUISrv.stopSpin();

        })
        .subscribe((res: any) =>
        {
            res.diagramNodeData.forEach((x) =>
            {
                let svgValue = x.MetaDataDTO.EditDTO.find(y => y.ColumnName == "SVGPath");
                if (svgValue.DataValue == null)
                {
                    x.SVGFile = svgValue.DefaultValue;
                }
                else
                {
                    x.SVGFile = svgValue.DataValue;
                }
            });

            let linkDataArray: any = [];

            for (let i = 0; i < res.diagramLinkData.length; i++)
            {
                let newLinkData = { DiagramConnectorType: '', FromEquipmentId: '', FromSocketId: '', Id: '', Points: '', Text: '', ToEquipmentId: '', ToSocketId: '', routing: go.Link.Orthogonal };
                newLinkData.DiagramConnectorType = res.diagramLinkData[i].DiagramConnectorType;
                newLinkData.FromEquipmentId = res.diagramLinkData[i].FromEquipmentId;
                newLinkData.FromSocketId = res.diagramLinkData[i].FromSocketId;
                newLinkData.Id = res.diagramLinkData[i].Id;
                newLinkData.Points = res.diagramLinkData[i].Points;
                newLinkData.ToEquipmentId = res.diagramLinkData[i].ToEquipmentId;
                newLinkData.ToSocketId = res.diagramLinkData[i].ToSocketId;
                newLinkData.routing = go.Link.Orthogonal;
                linkDataArray.push(newLinkData);
            }

            this.inputDiagram =
            {
                diagramNodeData: res.diagramNodeData,

                //link
                diagramLinkData: res.diagramLinkData,
                paletteNodeData: []
            };
            this.networkModelDiagramComponent.diagramRef.model = new go.GraphLinksModel(this.inputDiagram.diagramNodeData, this.inputDiagram.diagramLinkData);

            this.networkModelDiagramComponent.diagramRef.rebuildParts();

but the link not mapped as expected is anything i missed could you pls help me on this?

If you are replacing the value of Diagram.model you don’t need to call rebuildParts, which it will do automatically. That’s just wasting time and space.

So does your link template have a Binding on the Link.routing property, with a source property name of “routing”?

Yes i have that property


while initilize the diagram just rendering the default template and below get template i can define the templates

Wait – you don’t make use of linkDataArray.

What’s the value of Connectors.StarightLink?

I really cannot debug your code for you.

Hi That will select the template in the case 0: block (this is or first time when i initialize the diagram) am i need to give all the templates which i using in the diagram on the initialize?

You can certainly replace the Diagram.linkTemplate property with a different link template if you want all Links to look different.

If you merely want to change one or some Links, then using one or more Bindings in the link template and changing data properties in the model would make sense.

An intermediate approach would be to define several different link templates in the Diagram.linkTemplateMap and then the only data change that would be needed would be to set the link data “category” property to the desired link template name. Or call GraphLinksModel.setCategoryForLinkData.

Hi Walter i have fixed this by using templatemap and put the category in link data array .thanks