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
close icon

Disable autoscrolling when panning to old values

Hello,
I have a SfChart that shows a series of XY values horizontally.
The data is not fixed but it "increases" every second along the Y axis (see it as a real time plot of values along time). Using AutoScrollingDelta="20000" and AutoScrollingMode="End", I ensure that the most recent data is always visible (the most recent value is always plotted on the right edge).
Now I decided to activate the Panning functionality, so that the user can scroll to left and check the older values while new data continues to be added. The problem is that the user pans, but immediately the view returns back to the most recent values, I assume due to the AutoScroll.
I can detect when the panning starts (with Scroll event) so can I stop the AutoScroll function in that moment? Then I clould show a "reset" button to reactivate it.
Thanks for your support

1 Reply

MP Michael Prabhu M Syncfusion Team November 2, 2018 07:19 AM UTC

Hi Alessandro, 

Greetings from Syncfusion, we have achieved your requirement by setting AutoScrollingDelta as double.NaN during panning. We have reset the AutoScrollingDelta value in Scroll event and enable AutoScrollingDelta in button click.  Please refer below code snippet. 

Code snippet [XAML]:   
<StackLayout> 
        <Button Text="Enable AutoScrolling" Clicked="EnableAutoScrolling_Clicked"/> 
 
        <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Scroll="Chart_Scroll" > 
        ………….. 
        </chart:SfChart> 
 
</StackLayout>         
 
  
Code snippet [C#]:    
private void Chart_Scroll(object sender, Syncfusion.SfChart.XForms.ChartScrollEventArgs e) 
{ 
            e.Axis.AutoScrollingDelta = double.NaN; 
} 
void EnableAutoScrolling_Clicked(object sender, System.EventArgs e) 
{ 
            Chart.PrimaryAxis.AutoScrollingDelta = 30; 
} 
 

We have prepared a sample based on your requirement, you can download the sample from below link; 


Regards, 
Michael 


Loader.
Live Chat Icon For mobile
Up arrow icon