Scrolling ended event for sfchart

Hi,

I am using sfchart with datetimeaxis as primary axis and numerical axis as secondary axis.
Need to find a way to identify the point when user stops scrolling the chart.  Is there a event to indicate sfchart scroll ended? Below is the code sample i have.

Syncfusion xamarin forms Version : 16.1.0.26

<chart:SfChart  AutomationId="White" x:Name="Chart" Scroll="Chart_Scroll" Grid.Row="0" Grid.Column="1" Grid.RowSpan="8" Grid.ColumnSpan="2" Style="{StaticResource ChartStyle}" BindingContext="{Binding ViewModel}" >
                                    <chart:SfChart.PrimaryAxis>
                                       
                                        <chart:DateTimeAxis LabelCreated="DateTimeAxis_LabelCreated" Interval="1" ShowMajorGridLines="False" ShowMinorGridLines="False" 
                                                            AxisLineStyle="{StaticResource DateTimeLineStyle}" MajorTickStyle="{StaticResource GraphNoTickStyle}"/>
                                    </chart:SfChart.PrimaryAxis>
                                    <chart:SfChart.SecondaryAxis>
                                       
                                        <chart:NumericalAxis LabelCreated="NumericalAxis_LabelCreated" Interval="1" Minimum=".5" Maximum="5.5" IsVisible="false" MajorTickStyle="{StaticResource GraphNoTickStyle}"/>
                                    </chart:SfChart.SecondaryAxis>
                                    <chart:SfChart.ChartBehaviors>
                                       
                                        <chart:ChartZoomPanBehavior   EnableDoubleTap="False"  EnableZooming="False" EnablePanning="True" EnableSelectionZooming="False"/>
                                    </chart:SfChart.ChartBehaviors>
                                </chart:SfChart>
  

5 Replies

DV Divya Venkatesan Syncfusion Team June 5, 2018 09:31 AM UTC

Hi Naveen, 
 
Thanks for using Syncfusion products. 
 
We have achieved your requirement to identify the point when user stops scrolling the chart by defining an event ScrollEnd in a class extended from SfChart in ChartExt.cs file and extending ChartZoomPanBehavior in ChartZoomPanBehaviorExt.cs file. Please download the sample from the following link. 
 
 
Please let us know if you have any queries. 
 
Regards, 
Divya Venkatesan 
 



NA Naveen June 6, 2018 11:15 PM UTC

Thanks Divya.

I need another info. As you can see in my code, the primary axis is a date time axis.

When user stops scrolling, I would want to look at the dates being shown on primary axis and pick the first one.

Eg after scrolling ends, if the dates being shown on primary axis are:

3/12   3/13  3/14  3/15 

I want to access the first date that is 3/12 and use it for some calculation. How can I access  this?


DV Divya Venkatesan Syncfusion Team June 7, 2018 07:03 AM UTC

Hi Naveen, 
  
We have achieved your requirement to access the first label of primary axis by defining a bool variable and using LabelCreated event of axis. Please refer the below code snippets. 
  
Code snippet of ScrollEnd event[C#]: 
private void Chart_ScrollEnd(object sender, ScrollEndArgs e) 
{ 
    isScrollEnded = true; 
} 
  
Code snippet of LabelCreated event[C#]: 
private void DateTimeAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e) 
{ 
    if (isScrollEnded) 
    { 
        var firstLabel = e.LabelContent; 
        isScrollEnded = false; 
    } 
} 
  
Please let us know if you need any further assistance. 
  
Regards, 
Divya Venkatesan 
  
 



NA Naveen June 7, 2018 10:45 PM UTC

Divya,

This solution did not work. I do not get the first label that appears on primary axis.

I get some label but that is not the first one. Can you pls re check and update me.
You can add the code to your sample and try scrolling the screen couple of times to test. You will get to know that it does work as expected.

In short, what I am looking for is after scrolling stops, a way to inspect the primary axis and pick the first label .

BTW I want to pick the first label only when user scrolls back and not when he scrolls forward. Is there a way to identify if user is scrolling right or left?


PS Parthiban Sundaram Syncfusion Team June 22, 2018 04:30 AM UTC

Hi Naveen, 
  
Thanks for the patience.  
  
We have fixed the issue by overriding the TouchesCancelled method in ChartZoomPanBehaviorHelper class in the iOS platform and excluded the base method implementation of it. Please refer the following code snippet for details. 
  
Code snippet: 
  
   public class CustomZoomPanBehavior : ChartZoomPanBehaviorHelper  
    {  
        public override void TouchesCancelled(NSSet touches, UIEvent evt)  
        {  
  
        }  
    }  
  
 
  
 
Please let us know, if you need further assistance on this. 
  
Regards, 
Parthiban S.  


Loader.
Up arrow icon