In an older version of our product which is using 1.8.38 we have a very random bug when updating the model with new server data. This is the code that updates the model.
me.nodes = me.buildNodes(); me.links = me.buildLinks(); me.goDiagram.model = new go.GraphLinksModel(me.nodes, me.links);
Most of the time this triggers a model ChangedEvent with e.oldValue === ‘Initial Layout’ but every once in a while it doesn’t. I’ve tried all kinds of things including wrapping the above in a transaction but the GoJS says not to update model while in a transaction.
In 2.1 I changed how we do it but these model calls aren’t in 1.8 so no help.
diagram.startTransaction(tx); model.mergeNodeDataArray(nextProps.nodeDataArray); model.mergeLinkDataArray(nextProps.linkDataArray); diagram.commitTransaction(tx);
So in 1.8 what is the best way to replace an existing Diagram’s model with completely new data? My modelChangedListener performs logic on e.oldValue === ‘Initial Layout’ because our older apps link data doesn’t include start & end points, so when ‘Initial Layout’ doesn’t happen the diagram is incorrect.
Simple example of what the links look like.
This is what it looks like when I don’t get the ‘Initial Layout’.