-
We're in the middle of migrating microbetrace.cdc.gov from using d3.js to Unovis (Angular). I've looked at documentation and gallery examples, but I don't see how I can programatically trigger rerendering of the entire network to, for instance, trigger the nodeLabel function to run on all nodes after I change another variable that the nodeLabel function considers. For Example:
I have another function that changes the 'this.widgets['node-label-variable']', so then I want the nodeLabel function to be called on all nodes. Right now the node/link functions will only tigger for a specific node when I click on a node on the graph. I've tried change detection to see if that would work, but it doesn't appear to do anything either. Any prompt help would be greatly appreaciated, and love this tool! Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 13 replies
-
@mossy426 Excited to hear that! As far as I remember, you can trigger a change detection in Angular to make it re-render the graph:
@reb-dev Can you please check how we do it? If that doesn't help, you can try updating the entire data object like |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
https://stackblitz.com/edit/angular-zyybxk?file=src%2Fforce-graph%2Fforce-graph.component.ts Here is an example. I change the size variable after button click and now that the variable has been updated I want to update all the nodes. |
Beta Was this translation helpful? Give feedback.
-
Figured it out! I had to reassign a new data object, rather than a nodes array. Since the entire data object is what's being passed to the graph (not the nodes/links), you must reassign that object instead and it rerenders all nodes/links again. That being said, the whole network rearranges itself when rerendering, which may prove frustrating when you've moved everything into a specific position. |
Beta Was this translation helpful? Give feedback.
-
@mossy426 Right! Somehow I didn't think about it. Glad you were able to solve the problem. |
Beta Was this translation helpful? Give feedback.
-
@reb-dev Can you convert this into a discussion please so the others can see it. |
Beta Was this translation helpful? Give feedback.
Figured it out! I had to reassign a new data object, rather than a nodes array. Since the entire data object is what's being passed to the graph (not the nodes/links), you must reassign that object instead and it rerenders all nodes/links again.
That being said, the whole network rearranges itself when rerendering, which may prove frustrating when you've moved everything into a specific position.