Compute node position using a layout algorithm

4 posts, 1 answers
  1. Manuel
    Manuel avatar
    32 posts
    Member since:
    Sep 2013

    Posted 08 Dec 2013 Link to this post

    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...
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 11 Dec 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Manuel
    Manuel avatar
    32 posts
    Member since:
    Sep 2013

    Posted 11 Dec 2013 Link to this post

    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?
  5. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 14 Dec 2013 Link to this post

    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 >>
Back to Top