Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Flowchart links not as expected (Read 3524 times)
DavidZ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Jun 15th, 2013
Flowchart links not as expected
Jun 15th, 2013 at 5:12pm
Print Post  
I am building a flowchart programmatically. I have a series of decision boxes. If the answer is yes the link goes vertically down to the next decision box. If the answer is no the link should go from the right of the decision box to the end box at the bottom of the flowchart.

I am using the flowchart layout to arrange my diagram.

This works fine for the first decision box but for all the other ones the "no" links go vertical from the bottom of the box (exactly the same as the "yes" links).

From what I can see I am not creating the links from the first box any differently.

Thanks

David
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart links not as expected
Reply #1 - Jun 17th, 2013 at 8:39am
Print Post  
FlowchartLayout places outgoing links at the left and right sides of nodes only if there are two outgoing links, and if it can find a matching "end if" node where the if branches merge. However if only one of the branches contains intermediate steps, it will be centered below the if node, and the empty branch link will start from the side. For an example, see the JavaScript Parser sample project. So if your "no" branches are empty, you might have to insert some temporary nodes to ensure the layout places both branches to the sides.

Instead of FlowchartLayout, you might try using the layout code from WorkflowDesigner sample project - I think it always moves decision links to the sides of node, but it too requires "end if" nodes where the branches merge.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
DavidZ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Jun 15th, 2013
Re: Flowchart links not as expected
Reply #2 - Jun 17th, 2013 at 3:45pm
Print Post  
Thanks for the explanation. By putting a shape on the other branch I get the effect that I was after. Here is a before and after picture. Can you think of a way of achieving this without the intermediate nodes? I really do like the convenience of the flowchart layout. It means that I do not have to manage the layout which is a real bonus (unlike the workflow sample where there is a lot of extra layout work involved).

Thanks

David


Before After

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart links not as expected
Reply #3 - Jun 17th, 2013 at 5:34pm
Print Post  
If most of your flowcharts will be of that kind - a sequence of nodes with alternative empty branches going into an end node, try using TopologicalLayout instead:

Code
Select All
var tl = new TopologicalLayout();
tl.NodeDistance = 10;
tl.Orientation = MindFusion.Diagramming.Layout.Orientation.Vertical;
tl.Arrange(diagram);

diagram.ResizeToFitItems(5);

foreach (var link in diagram.Links)
{
	var start = link.StartPoint;
	var end = link.EndPoint;
	var mid = link.ControlPoints[1];

	link.Shape = LinkShape.Cascading;
	link.SegmentCount = 3;

	link.StartPoint = start;
	link.ControlPoints[1] = new PointF(mid.X, start.Y);
	link.ControlPoints[2] = new PointF(mid.X, end.Y);
	link.EndPoint = end;
	link.UpdateFromPoints();
} 





The code at the end converts the Bezier links to orthogonal ones.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
DavidZ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Jun 15th, 2013
Re: Flowchart links not as expected
Reply #4 - Jun 17th, 2013 at 7:11pm
Print Post  
Thanks, that looks good. There are cases where the "No"s go back into other decision boxes but I shall what happens when that arises.

Thanks

David
  
Back to top
 
IP Logged
 
DavidZ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Jun 15th, 2013
Re: Flowchart links not as expected
Reply #5 - Jun 18th, 2013 at 3:33pm
Print Post  
I am getting really close now! I have a scenario where there is one condition followed by to ORs e.g. is the first condition met? If so then one of two other conditions should also be met. It almost looks right (I am going to have to put up with the blank nodes or do something with them). However the last decision box does not work quite right. I am not sure why. I am using the same logic as the previous decision box but I don't know why it does not go out to the left to the "messages" node.

I am trying to keep this generic so that once I have managed ANDs, ORs and NOTs it should work for any combination of them. I have got it to work for the ANDs and NOTs but these ORs are proving harder.

Thanks again for all your help. Great product!

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart links not as expected
Reply #6 - Jun 19th, 2013 at 7:25am
Print Post  
Hi,

Unfortunately FlowchartLayout cannot work with arbitrary kinds of graphs. It expects that the diagram contains nested structures like loops, if branches, etc. and it cannot properly analyze the graph and discover how parts of it should be arranged if there are links jumping from within a branch to the outside of it (i.e. what would represent a goto statement). In your example the "is it incorrect .. false" -> "messages" part is properly nested within the larger if/else branch, but the "..equals 0" -> "end" link is not, and it causes problems.

If you cannot build your diagrams that way, try using other layout classes such as orthogonal or layered algorithms. With LayeredLayout you could do some post-processing to convert the links to orthogonal ones too, and move their origin to the sides of nodes.

Our developer will check in the next few days if we can extend FlowchartLayout to accept goto-like links, but with them it won't be possible to discover the structures in the graph entirely automatically, and you will have to specify what kind of logical structures are represented by nodes and links via their LayoutTraits dictionary.

Stoyan
  
Back to top
 
IP Logged
 
DavidZ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 22
Joined: Jun 15th, 2013
Re: Flowchart links not as expected
Reply #7 - Jun 19th, 2013 at 9:23am
Print Post  
Hi,

Thank you again for your explanation. I was having some difficulty getting my head around how you use control logic to steer the decision box links. However I used the javascript project to code the if, then, else clauses and realised exactly what you meant about the one link acting as a "goto". It is not possible to code that logic just using if then else.

As a compromise I have decided to add multiple messages as this seems to do the trick.

It would be great if goto could be included somehow in the flowchart layout.

Thanks

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