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

Getting start and end (date) from the PrimaryAxis?

Thread ID:

Created:

Updated:

Platform:

Replies:

142773 Feb 19,2019 11:06 AM UTC Feb 21,2019 11:36 AM UTC WPF 3
loading
Tags: SfChart
Sascha
Asked On February 19, 2019 11:08 AM UTC

Hi Syncfusion Support!

Is there any change to get and set the start (from) and end (to) value (for example date) for a zoomed PrimaryAxis of a SfChart? We are using so far ZoomPosition and ZoomFactor to have an experience for panning and zooming into our data. Of course, if we change start and end value of a SfChart the ZoomPosition and ZoomFactor have to recalculate to show the new "range" of data. 

Thank you!

regards,
Sascha

Muneesh Kumar G [Syncfusion]
Replied On February 20, 2019 10:51 AM UTC

Hi Sascha, 
 
Greetings from Syncfusion.  
 
We have analyzed your requirement and you can achieve this by getting calculated range in ActualRangeChanged event in axis and setting required range in event arguments as per the below code snippet.  
 
Code snippet 
    <chart:SfChart.PrimaryAxis> 
           <chart:CategoryAxis ActualRangeChanged="CategoryAxis_ActualRangeChanged"/> 
    </chart:SfChart.PrimaryAxis> 
 
 
        private void CategoryAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) 
        { 
            double min = (double)e.ActualMinimum; 
            double max = (double)e.ActualMaximum; 
            e.ActualMinimum = min + 1; 
            e.ActualMaximum = max - 1; 
        } 
 
 
Hope this helps you.  
 
Regards,   
Muneesh Kumar G.   
 


Sascha
Replied On February 20, 2019 12:19 PM UTC

Hi Syncfusion Support!

Thank you for your answer!

Regrettably, we do not get the required data. 

Here two screenshots to explain our requirements in more detail.


This is our SfChart without any zooming or panning. 

Now we are zooming & panning into the data. 


From your code we only get the start and end date from the "whole chart series range". Here some log when the event is firing:

CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
CategoryAxis_ActualRangeChanged - 20.02.2019 12:15:41 - 20.02.2019 12:59:59
Done with: Console.WriteLine($"CategoryAxis_ActualRangeChanged - {(DateTime)e.ActualMinimum} - {(DateTime)e.ActualMaximum}");
        
This meets exactly the dates from the first example. 

But we need 

 and 

If we have any chance to get these "dates"? It is not necessary that an event is firing. 

And, of course, we have to set these values for some important user experience! Perhaps a way to "recalculate" ZoomPosition and Factor? 

Thank you very much!

regards,
Sascha

Muneesh Kumar G [Syncfusion]
Replied On February 21, 2019 11:36 AM UTC

Hi Sascha, 
 
Thanks for your update.  
 
We have analyzed your requirement and you can achieve this by getting VisibleRange in axis and converting range values in to DateTime as per the below code snippet.  
 
Code snippet 
private void DateTimeAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) 
        { 
            var range = xAxis.VisibleRange; 
 
            if (!double.IsNaN(range.Start) && !double.IsNaN(range.End)) 
            { 
                DateTime min = DateTime.FromOADate(range.Start); 
                DateTime max = DateTime.FromOADate(range.End); 
            } 
        } 
 
    <chart:SfChart.PrimaryAxis> 
                <chart:DateTimeAxis x:Name="xAxis" ActualRangeChanged="DateTimeAxis_ActualRangeChanged"/> 
            </chart:SfChart.PrimaryAxis> 
 
We have prepared a sample based on this, please find the sample from the following location.  
 
 
Hope it helps you.  
 
Regards,  
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