Struggling with the basics and forcelayout
Joined: 19 Oct 2018
Topic: Struggling with the basics and forcelayout
Posted: 07 Aug 2019 at 4:26pm
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;
Width := 50;
Height := 30;
MyBlock.LinkPoints.Add((MyBlock.Right - MyBlock.Left)/2,MyBlock.top,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; //link start point to someblock
myLine.TargetLinkPoint.AnchorLink := atdgrmDiagram.Blocks[idx].LinkPoints; // link end point to anotherblock
Wagner R. Landgraf
Joined: 18 May 2010
|Post Options Quote Reply Posted: 10 Aug 2019 at 2:20am|
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.
|Forum Jump||Forum Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum