Auto Arrange of diagram

    function makePort(id, align, spot) {
      var port = $(go.Shape,
        {
          portId: id,
          alignment: align,
          cursor: "pointer",
          fromSpot: spot,
          fromLinkable: true,
          fromLinkableDuplicates: true,
          toSpot: spot,
          toLinkable: true,
          toLinkableDuplicates: true
        });
      if (align.equals(go.Spot.Top) || align.equals(go.Spot.Bottom)) {
        port.height = 4;
        port.stretch = go.GraphObject.Horizontal;
      } else {
        port.width = 4;
        port.stretch = go.GraphObject.Vertical;
      }
      return port;
    }

    myDiagram.nodeTemplate =
      $(go.Node, "Table",
        $(go.Shape,
          { fill: "lightgray" },
          new go.Binding("fill", "color")),
        makePort("T", go.Spot.Top, go.Spot.TopSide),
        makePort("L", go.Spot.Left, go.Spot.LeftSide),
        makePort("R", go.Spot.Right, go.Spot.RightSide),
        makePort("B", go.Spot.Bottom, go.Spot.BottomSide)
      );