Link's curviness question when link's visibility changes


According to api, if there are multiple links between two nodes, it will automatically compute reasonable values for the curviness of each link, unless you assign Link.curviness explicitly.

The question is, when some links’ visible change to false, they still hold the places. It will NOT recompute other links’ curviness.

To implement the “recompute”, i’m trying to override link.computeCurviness() , but i’m not sure what i should care about to compute curviness. Any tips, please…

Well, i override the function by myself ,and it seems like work well. Have NOT tested it for all situations.

    go.Link.prototype.computeCurviness = function () {

        if (!this.isVisible()) return 0;

        var fromNode = this.fromNode;
        var toNode = this.toNode;
        var links = fromNode.findLinksBetween(toNode);
        var linksVisible = new go.List(go.Link);

        links.each(function (obj) {
            if (obj.isVisible()) {

        var count = linksVisible.count;
        var firstLink = linksVisible.first();
        var position = linksVisible.indexOf(this);
        var space = this.computeSpacing();
        var degree = space * (count - 1);
        var curviness = (degree / 2) - (space * position);

        if (firstLink.fromNode !== this.fromNode) {
            curviness = -curviness;

        return curviness;

As long as the route or the curviness is not fixed, the routing of multiple links between the same pair of nodes will be recomputed if one or more of the links’ visibility changes.

Try selecting one or more links in this sample: [EDIT: obsolete]. Then click the “Toggle Visible” button one and two times. You can draw additional links if you like.

You’er right. I overrode link.computeSpacing() in a bad way, so that link.curviness was not computed correctly.Now i have fixed it. :-D