Problems updating a dataItem in a Force Directed chart.
I have hierarchical data loaded from a json file. And want to update the category on specific nodes in realtime. But I am unable to apply the validateRawData() method, which I beleave is needed to apply the changes.
So I have an updateNode() method which runs from a time eg.
function updateNode() {
let node = findNodeByName(series.dataItems, "Node2");
if (node) {
// Hard coded values just for testing
node.set("value", 555);
node.set("name'", "Node2Updated");
// Then tried various methods to apply the changes as commented below eg.
//series.data.validateRawData();
//node.get("value").invalidate();
// etc...
}
}
And my find function eg.
function findNodeByName(dataItems, nodeName) {
for (let item of dataItems) {
let name = item.get("category")
if (name === nodeName) {
console.log("Found node: '%s'", nodeName);
return item; // Found the node
}
let children = item.get("children");
if (children) {
let found = findNodeByName(children, nodeName);
if (found) {
console.log("Found: '%s'", nodeName);
return found;
}
}
}
console.log("Not found: '%s'", nodeName);
return null; // Node not found
}