Dynamically populate GraphSource through PopulateGraphSource method - RadDiagram

933 Views Asked by At

I am facing an issue where my graph is tree layout and looks fine initially. However, if I choose to change GraphSource upon user input/ clicks using PopulateGraphSource like in the OrgChart example, I get all the nodes stacked on top of each other with no links and all in corner.

I tried resetting graphSource by creating a new one

this.graphSource = new GraphSource();

I also tried to use the Clear method for GraphSource. Neither did solve the problem, I keep having the same issue.

I am using

ObservableCollection<Node> hierarchicalDataSource;

to fill up my GraphSource object.

All I do is create a new one and then call

PopulateGraphSource();

method.

Similar issues: question in telerik support , telerik support different question

1

There are 1 best solutions below

1
On

Try calling the Layout method on the diagram control. Here is a little fragment of code

TreeLayoutSettings settings = new TreeLayoutSettings()
        {
            TreeLayoutType = TreeLayoutType.TreeDown,
            VerticalSeparation = 60,
            HorizontalSeparation=30
        };

        if (this.diagram.Shapes.Count > 0)
        {
            settings.Roots.Add(this.diagram.Shapes[0]);
            this.diagram.Layout(LayoutType.Tree, settings);
            this.diagram.AutoFit();
            //this.diagram.Zoom = 1;
        }