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