This project is read-only.

Capture zoom state

Aug 4, 2015 at 9:03 AM
Hi,

I have a requirement wherein I need to store the zoom state of the plotter and then load it back when recreated. This doesn't seem to be straight forward. Has anyone attempted something like this before?

Thanks.

Cheers,
Ganesh
Aug 4, 2015 at 12:50 PM
Hi Ganesh,

You can try using "ViewportRestrictions". Not sure how far this works, I didn't try this.
Actually zooms you can Mange with plotter.Viewport.Visible. This works perfectly. Zoom states, previous zoom data/state and current zoom data/state you have to manage in your code.

Regards
Ravi.
Aug 5, 2015 at 11:21 AM
Thanks Battula. I have seen the Zoom methods on the Visible and ViewPort. It requires a Point to and factor. I'm not sure how to calculate that each time chart is zoomed. Would be great if you could provide a code snippet to handle that.

Cheers,
Ganesh
Aug 6, 2015 at 7:36 AM
Hi

You don't need to use zoom methods.
You have Y axis. I guess you know what should Y axis min value and max value, say these are yMin and yMax.
You have X axis, You will be knowing xMin and xMax. If your X axis is date time axis, then you have to convert date times to xMin and xMax.
The conversion is also very simple.
If your x axis name is timeAxis !
xMin = timeAxis.ConvertToDouble(StartTime);
xMax = timeAxis.ComverToDouble(endTime);
yMin = 0; // your y axis minimum value
yMax = 100; // your y axis maxmimum value
plotter.ViewPort.Visible = new Rect(xMin, yMin, xMax-xMin, yMax-yMin); // you will get your desired zoom in chart.
Hope this will full fill your requirement.
Check old desiscussions also, you will get more ideas. zooming also discussed earlier in the discussions.

Regards
Ravi
Aug 6, 2015 at 8:29 AM
Thanks battula. That helped. I'm able to store and restore the zoom state.
Aug 6, 2015 at 8:43 AM
Nice to hear that and you are welcome.

Regards
Ravi