Seats adding out of table

I implemented code for adding seats to the rectangle table after adding certain seats it is adding out of the rectangle. Now i want to add seats to within the length of the rectangle table
Here is the code

keyId = table.part.data.key;
sno = table.elements.count;
tblwidth = parseFloat(100 + parseFloat((sno - 4) * 20));
table.findObject(“TABLESHAPE”).desiredSize = new go.Size(tblwidth, 40);
pos1 = parseFloat(0.8 + parseFloat((sno - 4) * 0.2));
pos3 = pos1 + " " + pos2;
myDiagram.findNodeForKey(keyId).add(Seat(sno, pos3, “0.5 1”, 0));

This is image adding till 5 seats

This is the image adding after 5 seats

Now please help me how add seats within the length of the rectangle table dynamically

I suggest you learn about Spots and Spot Panels:
http://gojs.net/latest/intro/panels.html
http://gojs.net/latest/api/symbols/Spot.html

And about parseFloat:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat