Diagram layout problem with HierarchicLayoutManager

Hi,

i have the following problem. I have an small example with a main node which has 3 parent nodes and 2 child nodes. With the HierarchicLayoutManager i want to layout the diagram automaticly, but the layout result is unexpected. 


My current layout is as follow

synfusion diagram current.png


But what i want is the following

synfusion diagram expected.png


The automatic layouting for the child nides is correct, but the layouting for the parent nodes is not correct in my example.
Any Ideas what i'm doing wrong?
Attached is a small code example.

Thanks and best regards,
Thomas

        private void TestSyncfusionDiagramForm_Load(object sender, EventArgs e)
        {

            diagram1.Model = new Syncfusion.Windows.Forms.Diagram.Model();


            // Create Main Node

            var mainNode = new Syncfusion.Windows.Forms.Diagram.RoundRect(0, 0, 100, 70, MeasureUnits.Pixel);

            mainNode.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Main"));

            mainNode.FillStyle.Color = Color.FromArgb(255, 0, 0);

            diagram1.Model.AppendChild(mainNode);


            // Create CHild Nodes

            var childNodeOne = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 100, 70);

            childNodeOne.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Child One"));

            diagram1.Model.AppendChild(childNodeOne);


            var childNodeTwo = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 100, 70);

            childNodeTwo.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Child Two"));

            diagram1.Model.AppendChild(childNodeTwo);


            // Create Parent Nodes

            var parentNodeOne = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 100, 70);

            parentNodeOne.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Parent One"));

            diagram1.Model.AppendChild(parentNodeOne);


            var parentNodeTwo = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 100, 70);

            parentNodeTwo.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Parent Two"));

            diagram1.Model.AppendChild(parentNodeTwo);


            var parentNodeThree = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 100, 70);

            parentNodeThree.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label(mainNode, "Parent Three"));

            diagram1.Model.AppendChild(parentNodeThree);


            // Connect all nodes

            Connect(parentNodeOne, mainNode);

            Connect(parentNodeTwo, mainNode);

            Connect(parentNodeThree, mainNode);


            Connect(mainNode, childNodeOne);

            Connect(mainNode, childNodeTwo);


            // Set Layout

            var layout = new HierarchicLayoutManager(diagram1.Model, 0, 50, 50);

            this.diagram1.LayoutManager = layout;

            this.diagram1.LayoutManager.UpdateLayout(null);

            this.diagram1.UpdateView();

        }


        private void Connect(Node nodeFrom, Node nodeTo)

        {


            // Connector

            var conn = new LineConnector(PointF.Empty, new PointF(0, 1));

            // conn.VerticalDistance = 35;

            conn.LineStyle.LineColor = Color.Gray;

            // conn.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label() { Text = "ABCD" });


            Decorator decor = conn.HeadDecorator;

            decor.DecoratorShape = DecoratorShape.Filled45Arrow;

            decor.FillStyle.Color = Color.White;

            decor.LineStyle.LineColor = Color.Gray;


            this.diagram1.Model.AppendChild(conn);


            nodeFrom.CentralPort.TryConnect(conn.TailEndPoint);

            nodeTo.CentralPort.TryConnect(conn.HeadEndPoint);

        }



1 Reply

GG Gowtham Gunashekar Syncfusion Team June 28, 2021 01:57 PM UTC

 
Hi Thomas,  
  
Currently we don’t have multiple parent layout support in our diagram control. We have logged “Built-in automatic layout support for hierarchical tree with multiple parents” as a feature. We does not have any immediate plans to start this feature. We will implement this feature in any one of our upcoming releases.     
  
You can track the feature status from the below link  
  
  
  
Regards,  
Gowtham.  
 


Loader.
Up arrow icon