Page 1 of 1

How to limit pinch-and-zoom in Xamarin

Posted: Tue Feb 14, 2017 3:01 pm
by 18279984
We have a chart with a logaritmic scale. We would like to limit the smallest and the largest value for each axis, i.e. not letting the user scroll or zoom to see values smaller than 0.1 or larger than 10,000,000 (Our logaritmic base is 10).

We have managed to limit scrolling by listening to the Chart.Scroll event and manually setting the Axis.Minium or Axis.Maximum if the user scoll past the limits. But trying to do the same thing with pinch-n-zoom doesn't work since the Chart.Zoomed event isn't raised until the user lift their fingers.

Is there a way to either set limits on the axes themselves or only allow zooming in from default view (showing a subset of what was originally displayed) but not zooming out (showing more than was originally displayed)?

Re: How to limit pinch-and-zoom in Xamarin

Posted: Wed Feb 15, 2017 11:30 am
by Pep
Hello Robert,
which TeeChart Xamarin version are you using (Xamarin.Forms, Xamarin.iOS or Xamarin.Android) ?

Re: How to limit pinch-and-zoom in Xamarin

Posted: Mon Feb 20, 2017 12:35 pm
by 18279984
We're using Xamarin.Forms and are targeting both Android and iOS.

Re: How to limit pinch-and-zoom in Xamarin

Posted: Mon Feb 20, 2017 3:00 pm
by Pep
Hello Robert,

we've already added a new OnPinch event for Xamarin.Forms. It'll be available for the next maintenance release which will be published very soon.
But, in meantime you could use the OnBeforeDrawAxes event in order to check the minimum and maximum axis values and force a setMinMax for axis.
Here the code :

Code: Select all

       tChart1.BeforeDrawAxes += TChart1_BeforeDrawAxes;

        private void TChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            if (tChart1.Axes.Bottom.Minimum < 0)
            {
                tChart1.Axes.Bottom.SetMinMax(line.XValues.MinValue,line.XValues.MaxValue);
                tChart1.Draw();
            }
            else
                tChart1.Axes.Bottom.Automatic = true;
        }