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. Image for the cookie policy date

How to get visible range of DateTimeAxies

Hi, I have a question about how to get the visible range (DateTime values) from axis X (DateTimeAxies).

For example I have chart with DateTime (X) and values (Y). Load data from '2019-09-05 00:00:00.00' to '2019-09-05 14:35:00.00' (as attached picture). Now Zoom  -> then I want to get from chart datetime value (start and end) from axies X (for example '2019-09-05 07:02:00.00' to '2019-09-05 10:08:00.00').

How to do it?



Attachment: picture_3bfc1cb3.zip

1 Reply

MK Muneesh Kumar G Syncfusion Team September 6, 2019 08:56 AM UTC

Hi Tomas, 
 
Greetings from Syncfusion.  
 
We can able to get visible range using VisibleMinimum and VisibleMaximum properties of Axis, property returns double value present in the range.  
 
As we used DateTimeAxis, we should convert this value to date time by below.  
 
            var axis = chart.PrimaryAxis as DateTimeAxis; 
            viewModel.Label_Min = DateTime.FromOADate(axis.VisibleMinimum); 
            viewModel.Label_Max = DateTime.FromOADate(axis.VisibleMaximum); 
 
Using ZoomDelta and Scroll event of chart we can able to update range while zooming and scrolling. 
 
<chart:SfChart x:Name="Chart" ZoomDelta="Chart_ZoomDelta" Scroll="Chart_Scroll"> 
. . . 
</chart:SfChart> 
 
 
        private void UpdateLabel(SfChart chart) 
        { 
            var axis = chart.PrimaryAxis as DateTimeAxis; 
            viewModel.Label_Min = DateTime.FromOADate(axis.VisibleMinimum); 
            viewModel.Label_Max = DateTime.FromOADate(axis.VisibleMaximum); 
        } 
 
        private void Chart_ZoomDelta(object sender, ChartZoomDeltaEventArgs e) 
        { 
            UpdateLabel(sender as SfChart); 
        } 
 
        private void Chart_Scroll(object sender, ChartScrollEventArgs e) 
        { 
            UpdateLabel(sender as SfChart); 
        } 
 
We have prepared sample that will be downloaded from below link. 
 
 
Please let us know if you have any other queries.   
 
Thanks, 
Muneesh Kumar G 
 


Loader.
Up arrow icon