I have a list of node IDs (keys) and I need to highlight those nodes. For empty nodes, the same condition works fine. For example:
checkEmptyNodes() {
const emptyNodes = [];
const diagDetails = this.myserv.getDiagramData();
if (!!diagDetails.nodeDataArray) {
diagram.startTransaction('checking empty nodes');
diagram.nodes.each(n => {
if (!n.part.data.answer) {
emptyNodes.push(n);
}
});
diagram.highlightCollection(emptyNodes);
console.log(emptyNodes);
} else {
// data.answer = [];
}
diagram.commitTransaction('checking empty nodes');
return emptyNodes;
}
The above code is functional, but I also have similar code that doesn't throw any errors but doesn't highlight the nodes:
changeNodeColor(broken){
const brokenNodes = [];
diagram.nodes.each(n => {
if (broken.includes(n.Zd.key)) {
diagram.startTransaction('checking hanging nodes');
brokenNodes.push(n);
}
});
console.log("data here nk data");
console.log(brokenNodes);
diagram.highlightCollection(brokenNodes);
diagram.commitTransaction('checking hanging nodes');
return brokenNodes;
}
I'm unsure why the first code works and the second one does not. Any GoJS experts around?