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

Restore Diagram Position

5 Answers 164 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Vinod
Top achievements
Rank 1
Vinod asked on 09 Oct 2013, 09:32 PM
Hello,

My application shows a series of diagrams and implements a back-forward functionality on them. I do this by changing GraphSource.

However, I would like to preserve the position and zoom of the diagrams as the user goes back and forth. I'm trying to do this by setting the Position and Zoom properties on RadDiagram. However, the view is not correctly restored. I've verified that the correct position and zoom values are being set.

What is the recommended way to do this?

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 14 Oct 2013, 08:58 AM
Hi Vinod,

 Setting the Zoom and Position properties should work. Could you please elaborate more on your implementation, which other properties you use?  What goes wrong exactly, is it possible for you to provide some snapshots or to isolate a small sample reproducing the problem ? This way we would be better able to advice you. Thank you for your cooperation.

Regards,
Petar Mladenov
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
Dax Pandhi
Top achievements
Rank 1
answered on 09 Mar 2020, 04:28 PM

I am encountering the same problem.

Let's say I store the Position (point) and Zoom (double) properties to variables somewhere, then move the diagram around, then try to assign the saved property to the Diagram control, the restored position is NOT correct visually. It is correct value, but the offset (visually) is incorrect.

If I don't modify the Zoom property, the position works fine. I think Zoom is introducing an offset that is not being handled correctly. Or, the position is not being updated properly after zoom.

The problem seems to be related to the zoom position. Zooming in and out does not update the Position property.

0
Petar Mladenov
Telerik team
answered on 11 Mar 2020, 12:24 PM

Hello Dax,

Problem with zoom is that when you zoom with Mouse, the mouse position participates in the calculation and this can move the viewport. ViewPort is not saved / restored during save load. Here is a possible code you can use.

        private double savedZoomFactor;
        Point savedDiagramPosition;
        private void Save(object sender, RoutedEventArgs e)
        {
            savedZoomFactor = radDiagram.Zoom;
            savedDiagramPosition = radDiagram.Viewport.TopLeft;
        }

        private void Load(object sender, RoutedEventArgs e)
        {
            radDiagram.BringIntoView(savedDiagramPosition, savedZoomFactor);
        }

We would appreciate any feedback regarding this code. We will also try to include it in our documentation.

Regards,
Petar Mladenov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dax Pandhi
Top achievements
Rank 1
answered on 16 Mar 2020, 12:48 PM

Hi Petar,

Thank you so much! That did it. Haha - it was driving me crazy.

Might I suggest that when the docs are updated, this be made into a small how-to. Or at least a section in the pan/zoom article.

Thanks again,

Dax

0
Petar Mladenov
Telerik team
answered on 17 Mar 2020, 11:34 AM

Hello Dax,

I am glad to know you have resolved your issue. Yes, at least it will be added in the pan / zoom article.

Regards,
Petar Mladenov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Diagram
Asked by
Vinod
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Dax Pandhi
Top achievements
Rank 1
Share this question
or