How to change color of link when make a link

diagram.addDiagramListener(“LinkDrawn”, function (e) {
//I want to change here.And save the color in the link data.
}

Is there a Binding on the path Shape in your Link template? There should be, something like:

$(go.Link, . . .,
    $(go.Shape, new go.Binding("stroke", "color")),
    . . .
)

If so, then in your “LinkDrawn” DiagramEvent listener,

diagram.addDiagramListener(“LinkDrawn”, function (e) {
    var link = e.subject;
    e.diagram.model.set(link.data, "color", "green");
}
1 Like