Node location does not effect in diagram

myDiagram.commit((d:any) => { // d === myDiagram
console.log(d)
let x = 300;
var data = d.nodes[0]

        d.nodes.each((node:any) => {
          if (node.data.is_primary == true) {
            node.scale = 1.2;
            node.moveTo(x, node.position.y);
            //node.toSpot(200);
            // node.set(node.data, "color", "red");
            // node.locationSpot.y = 200;
            const shape = node.findObject("SHAPE");
            return
          }; 
         node.scale = 0.4; // shrink each node
        });
     
      }, "change position");

From above code my location is not rendering in the diagram and on the other hand node scale is working perfectly. can you please tell me how can we change the location of the node.

First I should point out that typing “: any” cancels out the benefits of TypeScript.

Second I should caution you that all of these statements are misleading and useless:

var data = d.nodes[0]
node.toSpot(200);
node.set(node.data, "color", "red");
node.locationSpot.y = 200;

Fortunately most of them are commented out, but I would delete them because they will confuse readers.

Otherwise your code looks like it should work. Confirm by examining their positions and locations afterward. Maybe they were already at position.x === 300?