Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Reduce the distance between particular nodes when arranging a diagram (Read 2285 times)
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Reduce the distance between particular nodes when arranging a diagram
Apr 7th, 2023 at 3:51pm
Print Post  
Hi,

In my VirtualizingDiagram, all nodes and links come from the lists assigned in the NodesSource and LinksSource properties. I'm arranging the diagram (the workaround was kindly suggested to me here) using a FlowchartLayout, where the layout.NodeDistance value is used to set the distance between nodes.

Code
Select All
    FlowchartLayout layout = new FlowchartLayout();
    ...
    layout.LinkPadding = 15;
    layout.NodeDistance = 100;
 



The fact is that the first node is a typical starting/initial node, and such a large distance to the next node is not required. The link will not have labels or anything. Is it possible to reduce the distance between nodes just for this case?

Thanks,
Kostya

PS: And I suppose I need to take into account that such a node may appear after alignment not only at the top. That is, not just move lower.
  

Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Reduce the distance between particular nodes when arranging a diagram
Reply #1 - Apr 10th, 2023 at 5:12am
Print Post  
Hi Kostya,

At this time there's no way to specify separate distance between a pair of nodes. For start node specifically, try just offsetting Bounds.Y / data-item's Y by half the Distance property value.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Reduce the distance between particular nodes when arranging a diagram
Reply #2 - Apr 10th, 2023 at 6:46pm
Print Post  
Hi Slavcho,

Thanks for your reply! Yes, I can move the initial node closer to the next one. But this works for straight links only. And maybe with a more complex diagram, it may turn out that such a "manual shift" will lead to an overlap with other links that will be between the nodes. In this regard, I would like to ask: can I "group" these first two nodes somehow, so that they maintain their relative positions? I mean something like to attach the initial state node strictly on one of the sides. So that when arranged, their location was taken into account to avoid overlaps (ArrangeTo()?).

Please let me remind you that the first node and link also come from NodesSource and LinksSource, not created in code as diagram objects.

Thanks,
Kostya
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Reduce the distance between particular nodes when arranging a diagram
Reply #3 - Apr 12th, 2023 at 7:50am
Print Post  
Hi Kostya,

If just offsetting the start node, you could check if it would intersect any unrelated links or other nodes on new position before committing to it, by calling item.Intersects(rect) method. If you find free space and offset the node, you could as well offset first one or two control points of start links depending on number of segments. I think setting node.Bounds would automatically offset these anyway if using LinkShape.Cascading.

There's also the diagram.Compact method you might try calling; not sure how well it will preserve the layout's overall shape.

You could place pair of nodes inside a temporary container, or grouping them and running with KeepGroupLayout enabled. The whole container / group would be considered a single node by the layout, but that might still lead to having to adjust or reroute links because they might be aligned according to the outer container and not to the paired nodes then.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Reduce the distance between particular nodes when arranging a diagram
Reply #4 - Apr 12th, 2023 at 1:45pm
Print Post  
Hi Slavcho,

Thanks much for your advice!

Kostya
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint