Struggling with the basics and forcelayout

This is my first run at the diagram studio and the lack of some really basic programmatic examples is making my head hurt.  I've spent about 1/2 a day on this and need to put it down for a bit, so a good time to ask a question.  I was trying to throw a load of ellipses (which represent a single rooted hierarchy) with a number of child ellipses.  It is action one ellipse per web page in a "up linked" site.

The following is cobbled from your examples and help file, so needs tidying obvs.
This just puts all the ellipses on top of each other and then I use the forceLayout example and it basically all the ellipses dissappear.  If you use the navigator, it looks like it makes the canvas / scroll area really really huge, i.e. the red box becomes a pixel.

I thought I could throw the 800 odd ellipses on there and it would lay them out for me.  While I am it, there are 10 examples?  I am looking for pretty basic programmatic manipulation of the diagram.


procedure TfraPageDiagram.AddObject(v: TjHTMLFile);
 MyBlock : TDiagramBlock;
 idx : Integer;
 myLine : TDiagramLine;
  MyBlock := TDiagramBlock.Create(atdgrmDiagram.Owner);
  with MyBlock do
    Left := 10;
    Top := 10;
    Shape := bsEllipse;
//    Text:=v.UpdatedFileName;
    Width := 50;
    Height := 30;
    Obj :=V;
    MyBlock.LinkPoints.Add((MyBlock.Right - MyBlock.Left)/2,,aoup);
    MyBlock.LinkPoints.Add((MyBlock.Right - MyBlock.Left)/2,MyBlock.bottom,aoDown);

    Diagram := atdgrmDiagram;

    if v.Parent <> nil then
      while idx >= 0  do
        if atdgrmDiagram.Blocks[idx].Obj = v.Parent then
          MyLine := TDiagramLine.Create(atdgrmDiagram.Owner);
          myLine.Diagram := atdgrmDiagram;
          myLine.SourceLinkPoint.AnchorLink := MyBlock.LinkPoints[0]; //link start point to someblock
          myLine.TargetLinkPoint.AnchorLink := atdgrmDiagram.Blocks[idx].LinkPoints[1]; // link end point to anotherblock

Hello Jason,

You provided the code that creates and places a new ellipse in the diagram. That code looks correct, and from what you said, I understand you confirms that part is ok?
Indeed all the objects are being placed in the same location (Left=10, Top=10). I would suggest you try to find a better placement for those ellipses, using some logic that fits your needs (add each ellipse X pixels from the right and Y pixels from the bottom of previous ellipse, for example, or just X pixels from the right until end of diagram area and then add Y pixels to bottom and X going back to 10, etc.).
The force diagram is not a strict layout diagram. It just simulates a repulsion force between all objects (they are "expelled" from each other). The parameters of the algorithm control how strong is that force, and how long the objects keep going away until they stop. You can try to reduce the RepulsionConstant parameter to see if it works. You can also play with the other parameters, when it comes to force layout you might need some try and error approach because the results really depend on your initial layout.