javascriptgojs

gojs seating chart - seat a guest by code


I'm using this example: https://gojs.net/latest/samples/seatingChart.html enter image description here We can seat a 'guest' by drag and drop events. However, I want to occupy a seat by code (create a node then seat a guest by code), with input is an object { id: "001", name: "Arya Stark", table : 3, seat: 1 }

How to do that?

Thanks you!


Solution

  • I haven't tried this, but maybe:

    var newguest = { key:"Arya Stark", table:3, seat:1 };
    myDiagram.model.commit(function(m) {
        m.addNodeData(newguest);
        positionPersonAtSeat(newguest);
    }, "added guest");