Auto size panel relative to grid cell size


I have a problem with setting the size of a node.

My node consists of a shape, textblock and a picture. The text in the textblock needs to set the size of the node, but the size of the node needs to be relative to the gridCellSize, because i have snap to grid enabled. Otherwise the link between a node that is above an other node will not (allways) be straight.

Hope someone can help.


my (simplified) nodetemplate

   $(go.Shape, { minSize: new go.Size(170,14) }),
   $(go.TextBlock, { margin: 10, height: 14 }),
   $(go.Picture, { alignment: spot }

Try setting { locationSpot: go.Spot.Center } on your Node.

Well it wasn’t what i wanted to do, but for now it fixed the problem :smile:


Maybe you also want to set DraggingTool.gridSnapCellSpot to Spot.Center?

  $(go.Diagram, "myDiagramDiv",
        "draggingTool.isGridSnapEnabled": true,
        "draggingTool.gridSnapCellSpot": go.Spot.Center,
        . . .

Hi Walther,

What does that do? Is it for the vertical alignment of the nodes?

That property controls the point relative to the grid that nodes are located.

I was just guessing as to what you wanted, since you did not say. And you did not show both what it is doing and how it is different from what you want.

right, sorry, was in a hurry atm.

my problem was that i enabled the snap-to-grid property, after that the links between nodes werent (always) straight if two nodes were positioned above eachother because of the difference in width (the text in the node sets the width).

So what i initially thought to be the most appropriate solution was to set the size of a node by the text in the textbox, but with values that are multiples of the cell size (like the resizeCellSize property does).

thats why i stated that it wasn’t what i wanted to do, but it fixed my problem :smile: