Change diagram entity positions programmatically

I have a diagram with entities and links and I’m trying to save and restore the entity positions.
I created a solution following this example and it works correctly.
Is it possible to avoid a complete diagram re-layout if I change only a subset of my entities?
In the example if I change in the “nodeDataArray” the location of an entity {"id":0, "loc":"300 300", "text":"Initial"} and I press “Load”, the diagram is reload as a new diagram.
Is it possible to move the entity if its location changed avoiding a complete re-layout?

I tried the following solution:

myDiagram.startTransaction("change Layout")
myDiagram.model.nodeDataArray[0].location = "500 500"
myDiagram.commitTransaction("change Layout")

and this one:

myDiagram.startTransaction("change Layout")
var first = myDiagram.model.nodeDataArray[0] 
var firstnode = myDiagram.findPartForKey( = "500 500"
myDiagram.commitTransaction("change Layout")

neither of them worked.


I found a solution

myDiagram.model.commit(function(m) {
  var data = m.nodeDataArray[0]
  m.set(data, "loc", "500 500")
}, "change location")

Yes, when changing a data property, it should always be done using Model.setDataProperty, or the shorthand Model.set.