Hi Sarthak Jagetia,
Greetings from Syncfusion, we have analyzed your sample and we like to explain the behavior of ZoomByRange method, this method has 3 parameters, axis and its range min and max, calling this method during initializing the chart is not recommended because chart will not be rendered and there will not be any axis with range assigned to it. So, the right way to use this method is when the chart is completely rendered and there is an axis to alter its range, you can achieve this requirement by using ActualRangeChanged event in ChartAxis class. Please refer below code snippet.
Code snippet [C#]:
private bool isLoadTime = true;
xAxis.ActualRangeChanged += XAxis_ActualRangeChanged;
private void XAxis_ActualRangeChanged(object sender, ChartAxis.ActualRangeChangedEventArgs e)
{
if (isLoadTime)
{
zoomPan.ZoomByRange(xAxis, enddate.AddSeconds(-1000), enddate);
}
isLoadTime = false;
} |
We have also modified the sample and it can be downloaded from the link below.
Thanks,
Michael