Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

I want to color node based on certain condition

$
0
0

@ram4unetcore wrote:

i am having id of nodes (key) , i want to highlight those node, for empty node the same condition works fine. ex :

    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 works but i have a similar code which is not giving any error but nodes are not getting highlighted

          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 have really no clue how the previous one work and why the second work does not . any gojs expert.

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles