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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to programmatically reset the zoom?

Thread ID:





124874 Jul 5,2016 08:30 PM UTC Aug 7,2018 11:56 AM UTC Xamarin.Forms 5
Tags: SfChart
Philippe Bourque
Asked On July 5, 2016 08:30 PM UTC

When I clear the data in my SFChart, the zoom become active and really zoom in (I don't why???).

Is it possible to reset the zoom programmatically?

This will help me to put the scope in a real fresh state after clearing the datas.



Yuvaraj Palanisamy [Syncfusion]
Replied On July 6, 2016 12:14 PM UTC

Hi Philippe Bourque,  
Thanks for contacting Syncfusion Support.  
Yes, you can use the following code example to reset the zoom in while clearing the data.  
Code Example [ C#]  
ChartZoomPanBehavior zoom = new ChartZoomPanBehavior();  

Philippe Bourque
Replied On July 6, 2016 01:45 PM UTC

Thank you Yuvaraj, it works! 


Yuvaraj Palanisamy [Syncfusion]
Replied On July 7, 2016 06:00 AM UTC

Hi Phil,

Thanks for your update.


Sarthak Jagetia
Replied On August 6, 2018 04:56 PM UTC

If I remove the button functionality in the sample provided and add the zoompan behaviour in OnCreate function, the chart does not automatically zoom in. 
How to achieve this?

Michael Prabhu M [Syncfusion]
Replied On August 7, 2018 11:56 AM UTC

Hi Sarthak Jagetia, 
Greetings from Syncfusion, we have analyzed your sample and we like to explain the behavior of ZoomByRange method, this method has 3 parameters, axis and its range min and max, calling this method during initializing the chart is not recommended because chart will not be rendered and there will not be any axis with range assigned to it. So, the right way to use this method is when the chart is completely rendered and there is an axis to alter its range, you can achieve this requirement by using ActualRangeChanged event in ChartAxis class. Please refer below code snippet.  
Code snippet [C#]:    
private bool isLoadTime = true; 
xAxis.ActualRangeChanged += XAxis_ActualRangeChanged; 
private void XAxis_ActualRangeChanged(object sender, ChartAxis.ActualRangeChangedEventArgs e) 
      if (isLoadTime) 
           zoomPan.ZoomByRange(xAxis, enddate.AddSeconds(-1000), enddate); 
      isLoadTime = false; 
We have also modified the sample and it can be downloaded from the link below. 
Sample: 211972 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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