- Welcome, Guest. Please Login or Register
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
Page Index Toggle Pages: 1 Send Topic Print  
How to tell LayeredLayout to consider areas in the arrangement?
Read 311 times

Erwin Lackner   Offline
YaBB Newbies
Posts: 1
I Love MindFusion!

How to tell LayeredLayout to consider areas in the arrangement?
Dec 17th, 2018 at 1:44pm
we are currently evaluating a purchase of MF 6.5.3 to automatically layout process plans based on given connection data.

Once we had looked at and tried out the various layout variants available, we chose LayeredLayout for our example. That looks quite reasonable.  (see screenshot ProcessPlanArrangedByLayeredLayout.png).

Additionally it is necessary to partition the process plan (respectively its nodes) into certain areas (see screenshot ProcessPlanArrangedAndLaoyutByArea.png).

But this causes us difficulties at the moment, because we don't find a way to tell the LayeredLayout that it considers this partitioning/placing of nodes to certain areas.

Can you give us a hint how to solve this problem?

Thanks in advance!
IP Logged    

Slavcho   Offline
God Member
Posts: 1597
Gender: male

Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #1 - Dec 18th, 2018 at 8:55am

There's nothing built into LayeredLayout to allow partitions. You could try SwimlaneLayout, or otherwise some post-processing for LayeredLayout to move nodes into areas preserving their relative placement from the layout and only changing Y:

var ll = new LayeredLayout();
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Horizontal;
ll.EnforceLinkFlow = true;

var columns = new Dictionary<int, List<DiagramNode>>();
foreach (var node in diagram.Nodes)
    if (!ll.Statistics.NodeLayerIndices.ContainsKey(node))
    var l = ll.Statistics.NodeLayerIndices[node];
    if (!columns.ContainsKey(l))
        columns[l] = new List<DiagramNode>();

foreach (var column in columns.Values)
    column.Sort((n1, n2) =>
            int area1 = (int)n1.Tag;
            int area2 = (int)n2.Tag;
            int areaComparison = area1.CompareTo(area2);
            if (areaComparison != 0)
                return areaComparison;
            return n1.Bounds.Y.CompareTo(n2.Bounds.Y);

    float y = diagram.Bounds.Top + 10;
    for (int i = 0; i < column.Count; i++)
        var node = column[i];
        int area = (int)node.Tag;
        float minAreaY = area * 70; // replace this with your area definitions
        if (y < minAreaY)
            y = minAreaY;
        node.Move(node.Bounds.X, y);
        y += node.Bounds.Height + 10;


IP Logged    
Page Index Toggle Pages: 1 Send Topic Print