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

Compute node position using a layout algorithm

3 Answers 29 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 08 Dec 2013, 02:33 PM
I'm trying to add a shape from code adding an element to the graphsource property.
Everything works as expected: the new shape is added to the diagram at position (0, 0) unless I set a different value.

Is it possible to compute a "meaningful" position using a layout algorithm?
Of course I can add the shape and then trigger a diagram layout, but this will affect the position of every shape...

3 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 11 Dec 2013, 02:45 PM
Hi Manuel,

I am not sure that I fully understand what you have in mind when you say "meaningful position". I assume that you need to layout only one of the shapes of the RadDiagram. If this is correct, you need to have in mind that the layout algorithm gets all the shapes of the diagram and lays them out together. Hence, with the current implementation of the control there is no easy way to achieve this requirement.

However, if my guess is not correct, you need to know that the Position property of the RadDiagramShape control can be bound to property exposed by your ViewModel. By doing this, you will be able to manually calculate the position of the shape and set it whenever you create the corresponding shape to your GraphSource.

I hope this sheds light on this. Please do not hesitate to ask if you have any other questions.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Manuel
Top achievements
Rank 1
answered on 11 Dec 2013, 02:57 PM
I'll try to clarify my requirements...

This is the use case
  • user decides that his preferred layout algorithm is "TreeLayout - Mindmap Vertical" so shape positions are auto-adjusted
  • user change some shape positions
  • an action performed by the user on the application (not necessarily on the diagram) triggers the creation of a new shape

I can't trigger a diagram re-layout: user's changes will be lost.
So I need to compute the new node's position, that depends on the selected layout.

Is there an easy way to accomplish this?
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 14 Dec 2013, 01:26 PM
Hi Manuel,

As I already mentioned in my previous post, there is no way to layout only part of the shapes (e.g. one shape) displayed by the RadDiagram component.

Please accept our apology for the inconvenience caused.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Diagram
Asked by
Manuel
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Manuel
Top achievements
Rank 1
Share this question
or