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

Is it possible to programmatically reset the zoom?

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.

Thanks,

Phil

5 Replies

YP Yuvaraj Palanisamy Syncfusion Team 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();  
zoom.Reset();  
   
  
Thanks,  
Yuvaraj  



PB Philippe Bourque July 6, 2016 01:45 PM UTC

Thank you Yuvaraj, it works! 

Phil


YP Yuvaraj Palanisamy Syncfusion Team July 7, 2016 06:00 AM UTC

Hi Phil,

Thanks for your update.

Thanks,
Yuvaraj
  



SJ Sarthak Jagetia August 6, 2018 04:56 PM UTC

Hi,
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?


MP Michael Prabhu M Syncfusion Team 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 
Thanks, 
Michael 




Loader.
Up arrow icon