getorgchart - I would like to dynamically assign color

179 views Asked by At

I have a scenario where I'm adding nodes to a root node based on the response of a REST service call.

I'd like to be able to assign the color of the fill of the object based on the node's "type" attribute - which I'm assigning from the REST payload.

For example, I have a root record with 4 address records, and 3 subsidiary records.

I'd live to the able to assign the address records green and the subsidiary records blue, but cannot see where to assign color base on a condition.

1

There are 1 answers

1
mjewler On

Try something like this.

var newNode = orgChart.insertNode(parentID, data);
var newNodeId = newNode.id;
orgChart.config.customize[newNodeId] = {color: "red"}
orgChart.loadFromJSON(orgChart.nodes, true);