We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to zoom chart with respect to pinch gesture orientation

Platform: Xamarin.Android |
Control: SfChart |
Published Date: September 20, 2018 |
Last Revised Date: September 20, 2018

You can zoom the chart independently on the orientation of pinch gesture using the ZoomMode property and IOnTouchListener interface. If you have the pinch gesture horizontally, the chart will be zoomed on the x-axis. If you have the pinch gesture vertically, the chart will be zoomed on the y-axis. Else, if the pinching position is diagonal, the chart will be zoomed on both the x and y-axes.

The following steps explain how to enable the pinch gesture zooming independently on the orientation of pinch gesture:

Step 1: Create a custom chart class inherited from SfChart and IOnTouchListener.

Step 2: Hook the Behaviors CollectionChanged event to get the ZoomPanBehavior.

Step 3: Access the root layout of chart, and set the touch listener using the GetChildAt and SetOnTouchListener methods.

Step 4: Implement the OnTouch interface method to get the touch positions of pinching, and set the ZoomMode value based on pinching.

Step 5: Use the custom chart class instead of SfChart in MainActivity.cs.

C#:

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile