Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144039 | Apr 15,2019 10:32 PM UTC | Apr 23,2019 11:03 AM UTC | Xamarin.Forms | 1 |
![]() |
Tags: SfChart |
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> |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.