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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get visible range of DateTimeAxies

Thread ID:

Created:

Updated:

Platform:

Replies:

147303 Sep 5,2019 01:07 PM UTC Sep 6,2019 08:56 AM UTC Xamarin.Forms 1
loading
Tags: SfChart
Tomas Turek
Asked On September 5, 2019 01:07 PM UTC

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

Muneesh Kumar G [Syncfusion]
Replied On 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 
 


CONFIRMATION

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon