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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

UWP- double tap zoom out doesnt work

Thread ID:

Created:

Updated:

Platform:

Replies:

144039 Apr 15,2019 10:32 PM UTC Apr 23,2019 11:03 AM UTC Xamarin.Forms 1
loading
Tags: SfChart
Emil
Asked On April 15, 2019 10:32 PM UTC

When i click double tap on andorid it zooms in and another double tap, zooms out.
I try the same action on UWP, zoom in works but zoom out wont work. below is my implementation of sfchart


                <chart:SfChart x:Name="Chart" SelectionChanged="Chart_SelectionChanged" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"  
                        >              
                    <chart:SfChart.PrimaryAxis>

                        <chart:DateTimeCategoryAxis AutoScrollingDelta="7"   AutoScrollingMode="End"  >

                            <chart:DateTimeCategoryAxis.Title>

                                <chart:ChartAxisTitle Text="{resx:Translate Date}"></chart:ChartAxisTitle>

                            </chart:DateTimeCategoryAxis.Title>

                        </chart:DateTimeCategoryAxis>

                    </chart:SfChart.PrimaryAxis>

                    <chart:SfChart.SecondaryAxis>

                        <chart:NumericalAxis  Minimum="0" Maximum="{Binding NumericalAxisMax}" Interval="{Binding NumericalAxisInterval}" >

                            <chart:NumericalAxis.Title>

                                <chart:ChartAxisTitle Text="{Binding NumericalAxisTitle}" ></chart:ChartAxisTitle>

                            </chart:NumericalAxis.Title>

                        </chart:NumericalAxis>

                    </chart:SfChart.SecondaryAxis>

                    <chart:SfChart.Series>

                        <chart:LineSeries EnableDataPointSelection="{Binding EnableDataPointSelection}"  XBindingPath="XValue" YBindingPath="YValue" 
                                  SelectedDataPointColor="Yellow"  ItemsSource="{Binding NumericMonthStats, Mode=OneWay}"  EnableAnimation = "true"
                                  AnimationDuration="0.8" >
                            <chart:LineSeries.DataMarker>
                                <chart:ChartDataMarker/>
                            </chart:LineSeries.DataMarker>
                        </chart:LineSeries>

                    </chart:SfChart.Series>
                    <chart:SfChart.ChartBehaviors>

                        <chart:ChartZoomPanBehavior x:Name="ZoomBehavior"  ZoomMode="X"/>

                    </chart:SfChart.ChartBehaviors>

                </chart:SfChart>


Bharathiraja K [Syncfusion]
Replied On April 23, 2019 11:03 AM UTC

Hi Emil, 
 
We have prepared the custom solution to achieve zoom in and zoom out by inheriting ChartZoomPanBehavior as a workaround for UWP. 
 
Please find the code snippet below. 
 
Note: Add below codes only for UWP. 
[C#] 
    public class CustomZoomPanBehavior: ChartZoomPanBehavior 
    { 
        protected override void DoubleTap(float pointX, float pointY) 
        { 
            if (Device.RuntimePlatform == Device.UWP) 
            { 
                if (EnableDoubleTap && !EnableSelectionZooming) 
                { 
                    var axis = Chart.PrimaryAxis; 
                    if (axis.ZoomFactor == 1 && axis.ZoomPosition == 0) 
                    { 
                        var seriesBound = Chart.SeriesBounds; 
                        var manipulationX = pointX - seriesBound.Left - Chart.ChartPadding.Left; 
                        var manipulationY = pointY - seriesBound.Top - Chart.ChartPadding.Top; 
 
                        var origin = GetOrigin(manipulationX, manipulationY, seriesBound.Width, seriesBound.Height, axis); 
 
                        Zoom(axis, 2.5f, origin); 
                    } 
                    else 
                    { 
                        Reset(); 
                    } 
                } 
            } 
            else 
            { 
                base.DoubleTap(pointX, pointY); 
            } 
        } 
 
        private static float GetOrigin(double manipulationX, double manipulationY, double width, double height, ChartAxis chartAxis) 
        { 
            float origin; 
            if (!chartAxis.IsVertical) 
            { 
                origin = (float)(chartAxis.IsInversed 
                    ? 1.0 - ((manipulationX - chartAxis.PlotOffset) / width) 
                    : (manipulationX - chartAxis.PlotOffset) / width); 
            } 
            else 
            { 
                origin = (float)(chartAxis.IsInversed 
                    ? (manipulationY - chartAxis.PlotOffset) / height 
                    : 1 - ((manipulationY - chartAxis.PlotOffset) / height)); 
            } 
 
            return origin; 
        } 
    } 
 
 
   <chart:SfChart.ChartBehaviors> 
            <local:CustomZoomPanBehavior ZoomMode="X"/> 
   </chart:SfChart.ChartBehaviors> 
 
And we have prepared the sample, that can be downloaded from below link. 
 
 
Regards, 
Bharathi. 


CONFIRMATION

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

Live Chat Icon For mobile
Live Chat Icon