Weak Link for Chart

Hello,

We have chart where user can create WeakLinks along with TreeLinks between nodes.

I need to set and get weak links properties eg: text, curviness and path using points of link. I am trying to set it like this as illusgtrated in http://www.gojs.net/latest/samples/stateChart.html.

foreachnode {

    var link = {
        category: "TreeLinks",
        from: dept['@PARENTNODECODE'],
        to: dept['@NODECODE']
    }
    linkDataArray.push(link)

    var link2 = {
        category: "WeakLink",
        from: dept['@PARENTNODECODE'],
        to: dept['@NODECODE'],
        text: "test link",
        curviness: "20"
    }
    linkDataArray.push(link2)
}

While links are being set, not able to set text property and path of link. And same is not available in myDiagram.model.linkDataArray.

Please suggest on how to do this.

What Bindings are you using in your link template(s)?

Hi,
Below are the code,

myDiagram.linkTemplateMap.add(“WeakLink”,
GO(go.Link,
{ curve: go.Link.Bezier, adjusting: go.Link.Stretch, isTreeLink: false, isLayoutPositioned: false, reshapable: true, relinkableFrom: true, relinkableTo: true, curviness: -50 },
{ routing: go.Link.AvoidsNodes },
GO(go.Shape,
{ stroke: OrgChartConfig.WeakLinkColor, strokeWidth: 2, strokeDashArray: [6, 3] }),
GO(go.Shape,
{ toArrow: “OpenTriangle”, stroke: OrgChartConfig.WeakLinkColor, strokeWidth: 2 })

                  )
                  );

and for drawing…

myDiagram.toolManager.linkingTool.insertLink = function (fromnode, fromport, tonode, toport, linkType) {
var drawlink = true
if (linkType) {
this.archetypeLinkData.category = linkType;
} else {
this.archetypeLinkData.category = “WeakLink”;
}

    myDiagram.model.linkDataArray.filter(function (x) {
            if ((x.category == "WeakLink") && (x.from == tonode.data.key) && (x.to == fromnode.data.key) || (x.category == "WeakLink") && (x.from == fromnode.data.key) && (x.to == tonode.data.key)) {
                alert('Linking already exists between the two nodes');
                myDiagram.currentTool.doCancel();
                drawlink = false;;
            }
    })

    if (drawlink) {
        return go.LinkingTool.prototype.insertLink.call(this, fromnode, fromport, tonode, toport);
    }
};

Thanks…

Hi,
I need functionality to delete the weak link. Like if user select link and press delete of keyboard then the selected link should be delete.

Use data Bindings. http://gojs.net/latest/intro/dataBinding.html
There are examples of this everywhere throughout the documentation.

Regarding deleting: if you haven’t set Part.deletable to false, nor Layer.allowDelete nor Diagram.allowDelete to false, the user should be able to delete a selected Part.
Most of the examples demonstrate this behavior.

I believe it is 2waybinding.

Hi,

I want to delete the weak link. I am able to delete the any selected node but not able to delete the weak link. Please see attached image.

I don’t know why you would need TwoWay Bindings in your link template, but what you showed above did not have any Bindings.

Can the user select the “weak link” OK? I don’t see deletable: false on your link template, so it ought to be deleted when the user selects it and deletes it.