I am dynamically changing node and link model data and don’t see the diagram updating. I looked at the API for nodes, links, and models and don’t see anything to notify that the model has changed. I did find diagram.rebuildParts() and it works but wondering if that is doing too much work for what I need? If I have a large diagram I don’t know if that will cause performance problems.
Is there a better way to let the diagram know that just a node or link model data has changed?
Here is what I have to modify existing node data. The first time it gets called I get the console message below but it doesn’t work. Debugging I do see that the node’s data property has been changed but the diagram doesn’t update to reflect it.
GraphLinksModel.setDataProperty is modifying a GraphObject, “Node#1422(Node Name1n)” go-debug.js:28
Is that really your intent? go-debug.js:28
Now if I continue and call the same code a 2nd time I don’t get the message above AND the diagram updates correctly. Any idea on what is going on? Here is my code.
There is a hard line between model data and diagram parts.
A Diagram holds Parts such as Nodes and Links, all composed of and inheriting from GraphObjects. (But Diagram is not a GraphObject.) These GraphObjects are rendered to the screen and can be manipulated by the user. But they are not part of any model. Typically you can get to the model data by getting the Part.data.
So the problem is that you are trying to modify GraphObjects using Model methods. I think you can just change the first argument to Model.setDataProperty from “node” to “node.data”.