Hi, I have a big problem. The problem is happened sometimes. It is not deterministic. So i cant solve. The problem is that when i refresh the diagram model (F5 page), Although the points of link are same. But view is shifting sometimes. It is not always happened. Do you have any idea? There are two images. Leftside is right but right side is wrong. Can you look it?
If you interactively select and move one of the nodes, do any or all of the links get “fixed”?
How are those link template(s) defined?
No, i dont move any nodes. In fact i take location of the nodes and points of the links from server. So node data and link data is not change. And this diagram is read only.
Thank you for answer.
My link template is
myDiagram.linkTemplate =
$(go.Link,
{
routing: go.Link.Normal,
curve: go.LinkJumpOver,
corner:5, resegmentable: true, reshapable: true,
adjusting: go.Link.Stretch
},
new go.Binding(“points”).makeTwoWay(),
$(go.Shape,
new go.Binding(“stroke”,“color”)
)
)
I realize something that is set interval.
i change property of some node with set interval. So i change the model of diagram. it corrupt the view ?
setInterval(functionName,2000)
functionName = function () {
var arr = myDiagram.model.nodeDataArray;
arr.forEach(function(item,index){
if(item.category == “Label”) {
myDiagram.startTransaction(“Change Model”)
var value = (Math.random()*100).toString()
myDiagram.model.setDataProperty(item,“label”,value)
myDiagram.commitTransaction(“Change Model”)
}
})
I used transaction when i change the model, Do you have any other idea. Thank you for your interest
Oops I got error,
Do not replace a Diagram.model while a transaction is in progress.
I think setInterval dont wait the transaction. Is it possible?
But this error appear after adding the transaction in my load function. After receiving the data from server,
i change the model with this
myDiagram.model = go.Model.fromJson(this.responseText)
But i add transaction here also. Result do not replace a diagram.model while a transaction is in progress. But set interval is inactive.
myDiagram.startTransaction(“start”)
myDiagram.model = go.Model.fromJson(this.responseText)
myDiagram.commitTransaction(“start”)
A Model has an UndoManager, so it doesn’t make sense to try to maintain a transaction while replacing a Diagram.model.
But as long as a model is being displayed by a diagram, whenever you want to make a change to the model, all of those changes should be grouped into short transactions. That is true for all predefined commands and tools. In your case I am guessing once per timer interval.
Regarding your code, above, you should not be executing transactions within loops. Please read GoJS Transactions -- Northwoods Software