Change color of a nodes links after it has already

How do I change the color of a nodes links are the diagram has already been drawn?

Thanks!

If there’s a Binding on the Shape.fill or Shape.stroke on some data property, you can just call Model.setDataProperty to modify the color of the link.

I think there are some examples of this – search the samples for setDataProperty and Binding.

[QUOTE=walter]

If there’s a Binding on the Shape.fill or Shape.stroke on some data property, you can just call Model.setDataProperty to modify the color of the link.

I think there are some examples of this – search the samples for setDataProperty and Binding.[/quote]

Thanks walter! I will post any solution I come up with here.

Actually, I was making an assumption that you wanted to have some kind of coloring information in your model, as a property on your link data or node data.

Normally the expectation is that all model state can be saved and reloaded later. So if you did not want that coloring information to be persistent, you should not put it on the link data or node data.

For example, you might want to highlight a path based on some user request, but that path does not want/need to be saved in the model. In these cases you cannot use data binding on the model data. You might need to modify the Shape.fill or Shape.stroke directly. An example is shown in the Friend Wheel sample (http://gojs.net/latest/samples/friendWheel.html). That demonstrates how a mouse-over a Link can highlight it and the connected Nodes, and how selecting a Node highlights the links and nodes connected with it.

Ah ok. The wheel example helps a lot! After fumbling a bit I had come up with a function to highlight the links out of a node when the node was selected but it is not as complete as what is in the wheel example. Here is what I started with as it may help someone be able to understand what is going on in the wheel example if they would like to highlight links.

function highlightLinkPaths(node)
{
diagram.startTransaction(“changed color”);
var links = node.findLinksConnected();
while (links.next())
{
links.value.path.stroke = “lightblue”;
}
<span =“Apple-tab-span” style=“white-space:pre”> diagram.commitTransaction(“changed color”);
}