Is it possible to create node bindings with go.Node property?
I have a tree where I want to color each node based on its depth. I want to use findTreeLevel function for the same. But
new go.Binding("fill", "", (node) => console.log(node))
seems to log the node data object only. Is it possible to bind the node to depth in some way?
Never mind. I got it.
new go.Binding("fill", "", (node) => {
const nodeDepth = node.findTreeLevel();
switch(nodeDepth)
{
case 0: return "white"
case 1: return "#bee5d3"
case 2: return "#d6b0b1"
case 3: return "#f0c38e"
case 4: return "#f1aa9b"
default: return "#3b5360"
};
}).ofObject()
This works for me.
For anyone who comes looking for this, here is the reference to where I found the solution - GoJS Data Binding -- Northwoods Software