[Seating map] _ Fixed distance between seats

Dear all,

I’m using this function to generate seats.

      function RecSeats(total, seatAlign) {
            var seats = [];
            
            if (total > 0) {
                let px = seatAlign;
                let py = 0;
                
                for (var i = 1; i <= total; i++) {                    
                    console.log(px);
                    
                    if(i % 2 === 0){
                        seats.push(Seat(i, new go.Spot(px, 1))); 
                        px = px + seatAlign;
                    }else{                        
                        seats.push(Seat(i, new go.Spot(px, 0)));
                    }
                    
                    console.log(new go.Spot(px, py)); 
                }
            }
            
            return seats;
        }

It generates seats opposite like this as my expectation.

image

The problem is the distance between seats is not fixed.
I want it is fixed based on input value.
So the distance between seat 1, 3, 5, … for both tables should be as the same.
Thanks you in advanced.

Yes, the Spot.x and Spot.y values are fractions of the total width and height of the main element (the table panel/shape in this case). Thus the distance between them will depend on the total width.

You could try using the Spot.offsetX and Spot.offsetY properties instead, since those properties are absolute values rather than fractions from 0 to 1.

Dear @walter,
Thanks for your replying.
Could you demonstrate to use Spot.offsetX and Spot.offsetY?
I thought something like this:
Seat(i, new go.Spot(x, y, offsetX, offsetY))
But still not figure out how to use.
Thanks in advanced.

What have you tried?

Dear @walter,
I tried to put some code like this
const ox = 3; Seat(i, new go.Spot(0, 0, ox, 1));
However it is not working.

That’s the right idea – for each of the seats at the top, use new go.Spot(0, 0, x, 0) where you increment x each time by the width of the seat plus the spacing you want.

Dear @walter,
I tried this:

function RecSeats(total, seatAlign) {
    if (total > 0) {
        let ox = 5;
        
        for (var i = 1; i <= total; i++) {
            seats.push(Seat(i, new go.Spot(0, 0, ox, 0)));
            
            console.log(Seat(i, new go.Spot(0, 0, ox, 0)));
            
            ox = ox + 10;
        }
    }
    
    return seats;
} 

and it display all seat at one.
image
what is it wrong?

The Seat function defined in the Seating Chart sample takes three arguments, not two. You need to pass something reasonable as the third argument. I don’t know what that is for what you want to do, but you could at least start with passing go.Spot.Center as the third argument, and then adjust it as you deal with different seating geometries.