This is a migrated thread and some comments may be shown as answers.

RadDiagram TreeDown

2 Answers 263 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Gregor
Top achievements
Rank 1
Gregor asked on 14 Oct 2014, 07:04 AM
Good day,

I'm wondering how can I fix wrong positioning (you can see how does it look right now in attached picture) of RadDiagramShapes in TreeDown? When I have like 5 nodes it works quite OK. But when i have let's say 90 nodes it becomes a mess.

I use this code after i fill RadDiagram with shapes and after i connect them with each other.
TreeLayoutSettings settings = new TreeLayoutSettings()
{
    TreeLayoutType = TreeLayoutType.TreeDown,
};
settings.Roots.Add(rd.Shapes[0]);
  
rd.RoutingService.Router = new OrgTreeRouter()
{
    TreeLayoutType = TreeLayoutType.TreeDown,
    ConnectionOuterSpacing = 20,
};
rd.LayoutAsync(LayoutType.Tree, settings);
rd.AutoFitAsync(new Thickness(0, 0, 0, 0), false);


I have only one root and I have already tried with positioning root shape on some position. Also i tried to fit layout after each diagram was put on diagram.

Thanks for your help.

Regards,

Gregor

2 Answers, 1 is accepted

Sort by
0
Gregor
Top achievements
Rank 1
answered on 14 Oct 2014, 07:05 AM
I forgot to attach the picture.
0
Zarko
Telerik team
answered on 16 Oct 2014, 07:50 AM
Hello Gregor,
Here I'll copy/paste my answer from the support thread so that other customers with similar problems may read it:
As far as I understand the issue is that some of the children are stretched far to the right or left is that correct ? This actually is by design - in the tree layout places every child so that there are no shapes from another branch underneath it. Unfortunately this is not easily customizable at the moment and you'll have to chose one of the workarounds:
1) Handle the diagram's DiagramLayoutComplete event and manually move the stretched items
2) Instead of the Layout method use save/load - first you'll need to manually layout the diagram as desired, save it to an xml/string and then whenever you want you could load it with the saved layout.
3) Implement your own TreeDown layout. To do this you'll need a custom layout service:

public class MyLayoutService : ILayoutService
{
    public bool IsLayouting
    {
        get;
        private set;
    }
 
    public void Layout(LayoutType type, object settings)
    {
        this.IsLayouting = true;
        // Implement your layout here.
        this.IsLayouting = false;
    }
}
And then you'll have to register it to the diagram:
this.diagram.ServiceLocator.Register<ILayoutService>(new MyLayoutService());
I hope I was able to help.


Regards,
Zarko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Diagram
Asked by
Gregor
Top achievements
Rank 1
Answers by
Gregor
Top achievements
Rank 1
Zarko
Telerik team
Share this question
or