2

I am trying to modify David Bacci's Org Chart. https://github.com/PBI-David/Deneb-Showcase/tree/main/Organisation%20Tree%20Chart. My goal is to change the color of the node borders based on conditional formatting rather than color matching a flow. I cannot figure out how/where to add the conditional formatting based on a table column. I have tried multiple codes/locations to no avail. Thank you for any help.

I have a Status column in my data: Onboarded, In-processing, Leaving. Below is core code attempt. I do not want that text to appear in the blocks. I just want each node to have a different color border. I have also tried single/double quotes, adding layers, encoding within the nodes, nada.

Example of Org Chart with data

{
  "encode": {
    "color": {
      "condition": [
        {
          "test": "datum.Status == 'Onboard'",
          "value": "green"
        },
        {
          "test": "datum.Status == 'Inprocessing'",
          "value": "yellow"
        }
      ],
      "value": "red"
    }
  }
}
1
  • It would be helpful if you edited your question and included more details so that those who are unable to access that link are able to understand your problem. For example, I have no idea what you mean by, "I do not want the text to appear in the blocks" if I'm not able to access that link. Commented Jun 27 at 16:40

1 Answer 1

0

This is Zornitsa from BALKAN App

Here is how you can easily achieve that with OrgChart JS:
If you have this data:

let nodes = [
    { id: 1, Person: "Mark", kpi: "Branch Chief", Level2ID: 2 },
    { id: 2, pid: 1, Person: "Mark", Status: "Inbound", kpi: "Branch Chief", Level2ID: 2 },
    { id: 3, pid: 1, Person: "Sam", Status: "OnBoard", kpi: "Branch Chief", Level2ID: 2 },
    { id: 4, pid: 1, Person: "Sara", Status: "InProcessing", kpi: "Branch Chief", Level2ID: 2 }
];

Add tags based on the Status:

for (let i = 0; i < nodes.length; i++) {
    let node = nodes[i];
    switch (node.Status) {
        case "OnBoard":
            node.tags = ["OnBoard"];
            break;
        case "InProcessing":
            node.tags = ["InProcessing"];
            break;
        case "Inbound":
            node.tags = ["Inbound"];
            break;
    }
}

then add the CSS for these tags:

.node.OnBoard rect {
    stroke: green;
}

.node.InProcessing rect {
    stroke: yellow;
}

.node.Inbound rect {
    stroke: red;
}

Here is the result:
enter image description here

Here is the full example:
https://code.balkan.app/org-chart-js/david-bacci#JS

Here you can find more simple example without the David Bacci's like styling.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.