ZoomIn and ZoomOut based on Y-Axiz values

Jun 23, 2013 at 11:24 AM
Hi Team,

Currently, I have developed a graph using ChartPlotter and Im trying to achieve a functionality where user can provide maximum and minimum values of Y-axis in a text box or slider, so that chart/graph should fit into user given MIN and MAX range of Y-Axis. I don't bother about X-axis range, best way could be change the X axis range in proportion to Y-axis range.

I came across several posts on all types of "Restrictions" and tried accessing current range of X-axis and Y-axis values using plotter.ViewPort.Visible, but, failed to implement such functionality. There is a functionality called BringIntoView() on top of ViewPort of plotter object, but, not sure how to use this function. :(

Could you, anyone, please suggest me on how to achieve this Fit To Y Axis Range functionality. Help to this question would be a lot to me and thanks in advance.

Regards,
Kumar
Jun 28, 2013 at 3:06 AM
Kumar,

I had to set several items to get this same type of functionality:

Add a DomainRestriction of the proper size.
Setup Viewport.Domain of the proper size.
setup a Viewport.Visible rectangle for initial display
setup a MinimalWidthRestriction for zoom in
setup a MaximalSizeRestriction for zoom out
Jul 3, 2013 at 1:16 PM
smonsees wrote:
Kumar,

I had to set several items to get this same type of functionality:

Add a DomainRestriction of the proper size.
Setup Viewport.Domain of the proper size.
setup a Viewport.Visible rectangle for initial display
setup a MinimalWidthRestriction for zoom in
setup a MaximalSizeRestriction for zoom out
Hi smonsees,

Thanks for the reply. Luckily, I managed to get what I wanted and here is how.
           Rect rect = plotter.Viewport.Visible.ViewportToData(plotter.Viewport.Transform);
            double factor = Convert.ToDouble(maxYvalue - minYvalue) / rect.Height;
            Rect newRect = new Rect() { X = rect.X, Y =minYvalue, Height = rect.Height * factor, Width = rect.Width * factor };
           if (!rect.IsEmpty)
            {
                Rect test = newRect.DataToViewport(plotter.Viewport.Transform);
                plotter.Viewport.Visible = test;
            }
Hope, this solution is helpful to others who are in need of it.

Regards,
Kumar
Dec 26, 2013 at 7:44 AM
Hi Kumar,

Saw your above post, similar to something which I am trying to do as well. I want to get the Min and Max values of the horizontal and vertical axes currently on display. i.e. once I zoom in/out the current linegraph on my chartplotter, I want to extract the current starting and ending values of both axes using a button click or something. Seeing your above solution, I think it is for setting those values. Any idea on how to extract those values? Your reply is much appreciated.

Thank you!
Dec 28, 2013 at 2:11 AM
Edited Dec 28, 2013 at 2:11 AM
        var v = plotter.Visible;
        int X_left = Convert.ToInt32(v.Left);
        int X_right = Convert.ToInt32(v.Right);