<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis EnableAutoIntervalOnZooming="False" IntervalType="Minutes" Interval="15" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" >
<chart:DateTimeAxis.LabelStyle >
<chart:ChartAxisLabelStyle TextColor="White" LabelFormat="hh mm" >
</chart:ChartAxisLabelStyle>
</chart:DateTimeAxis.LabelStyle>
</chart:DateTimeAxis>
</chart:SfChart.PrimaryAxis> |
<chart:SfChart x:Name="ChartControl" ZoomStart="ChartControl_ZoomStart" ResetZoom="ChartControl_ResetZoom" ZoomDelta="ChartControl_ZoomDelta" ZoomEnd="ChartControl_ZoomEnd" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis x:Name="XAxis" EnableAutoIntervalOnZooming="False" IntervalType="Hours" Interval="4" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" ShowMajorGridLines="False" ShowMinorGridLines="False">
<chart:DateTimeAxis.LabelStyle >
<chart:ChartAxisLabelStyle LabelFormat="HH mm" >
</chart:ChartAxisLabelStyle>
</chart:DateTimeAxis.LabelStyle>
</chart:DateTimeAxis>
</chart:SfChart.PrimaryAxis>
. . .
. . .
</chart:SfChart> |
private void ChartControl_ResetZoom(object sender, ChartResetZoomEventArgs e)
{
ZoomPan.IsInvokeTapZoomIn = true;
XAxis.IntervalType = DateTimeIntervalType.Hours;
XAxis.Interval = 4;
XAxis.EnableAutoIntervalOnZooming = false;
}
//At Zoom start
private void ChartControl_ZoomStart(object sender, ChartZoomStartEventArgs e)
{
ResetIntervals();
}
//Resetting the intervals.
private void ResetIntervals()
{
ZoomPan.IsInvokeTapZoomIn = false;
if (XAxis.ZoomPosition == 0 || XAxis.ZoomFactor == 1) //Default values
{
XAxis.IntervalType = DateTimeIntervalType.Hours;
XAxis.Interval = 4;
}
else
{
XAxis.IntervalType = DateTimeIntervalType.Minutes;
XAxis.Interval = 15;
}
XAxis.EnableAutoIntervalOnZooming = false;
} |
public class CustomBehavior: ChartZoomPanBehavior
{
public bool IsInvokeTapZoomIn = true;
//Invoke while doble tap on chart.
protected override void DoubleTap(float pointX, float pointY)
{
if (Chart != null)
{
if (IsInvokeTapZoomIn)
{
IsInvokeTapZoomIn = !IsInvokeTapZoomIn;
(Chart.PrimaryAxis as DateTimeAxis).IntervalType = DateTimeIntervalType.Minutes;
(Chart.PrimaryAxis as DateTimeAxis).Interval = 15;
}
else
{
IsInvokeTapZoomIn = !IsInvokeTapZoomIn;
(Chart.PrimaryAxis as DateTimeAxis).IntervalType = DateTimeIntervalType.Hours;
(Chart.PrimaryAxis as DateTimeAxis).Interval = 4;
}
Chart.PrimaryAxis.EnableAutoIntervalOnZooming = false;
}
base.DoubleTap(pointX, pointY);
}
} |
<chart:SfChart.ChartBehaviors>
<local:CustomBehavior x:Name="ZoomPan" ZoomMode="X" EnableDoubleTap="True" EnablePanning="True" EnableZooming="True" />
</chart:SfChart.ChartBehaviors> |
Fig: before zoom in
|
Fig: After zoom in
|