How can I change parent-child relationships stroke color

Hello,

I need to use color for stroke from nodeData for parent-child relationships.

   // the representation of each label node -- nothing shows on a Marriage Link

myDiagram.nodeTemplateMap.add(“LinkLabel”,

    $(go.Node, { selectable: false, width: 1, height: 1, fromEndSegmentLength: 20 }));

  myDiagram.linkTemplate =  // for parent-child relationships
    $(go.Link,
      {
        routing: go.Link.Orthogonal, curviness: 15,
        layerName: "Background", selectable: false,
        fromSpot: go.Spot.Bottom, toSpot: go.Spot.Top
      },
      $(go.Shape, { strokeWidth: 2,stroke:/* **Here I need to use color from nodedata***/})
    );   

  myDiagram.linkTemplateMap.add("Marriage",  // for marriage relationships
    $(go.Link,
      { selectable: false },
      $(go.Shape, { strokeWidth: 2, stroke: "blue" })
  ));
  setupDiagram(myDiagram,[{ key: 0, n: "Aaron", s: "M", m:-10, f:-11, ux: 1, a: ["C", "F", "K"] , stroke: ""},{ key: 1, n: "Aaron-wife", s: "f",  ux: 0, a: ["C", "F", "K"], stroke: "" },{ key: 2, n: "Aaron-son1", s: "M", m:1, f:0, ux: 1, a: ["C", "F", "K"], stroke: "red" },{ key: 3, n: "Aaron-son2", s: "M", m:1, f:0, ux: 1, a: ["C", "F", "K"], stroke: "yellow" }]

Yes, that is the Shape whose stroke you want to change. Does the child’s data ever change? If not, you can transfer the property to the link data when the code creates the parent-child link, and you can use a simple data Binding on the links Shape.stroke property.

Is it possible for parent-child links shows in different colours

Yes, you can, but that is a different question than this topic started with, because now it appears that you do not want the color to be determined for each parent-child link by a property on the child data object.

So what is to determine the colors now?

For parent-child relation in a family , it should be distinct color compared to another family.

OK, I’ll interpret each “family” to mean each “marriage”. Which means that for each label node on each “Marriage” link you can modify all of the connected links.

I can’t help you with choosing the actual colors. But you could do something like:

myDiagram.links.each(function(link) {
    if (link.category === "Marriage") {
        var node = link.labelNodes.first();
        var color = . . .;
        node.findLinksConnected().each(function(childlink) {
            childlink.path.stroke = color;
        }
    }
});