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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTimeCategoryAxis How to convert Axis coordinates to DateTime

Thread ID:





116116 Apr 4,2014 07:05 AM UTC Apr 4,2014 12:17 PM UTC WPF 1
Tags: SfChart
Rodolphe Billottet
Asked On April 4, 2014 07:05 AM UTC

I'm changing from DateTimeAxis to DateTimeCategoryAxis.  (adviced by Syncfusion  http://www.syncfusion.com/support/forums/wpf/chart/115787 )
And some feature I had developped with DateTimeAxis are not working anymore with DateTimeCategoryAxis.
Especially Axis coordinates to DateTime conversion.  which is logical because I was using linear conversion and the DateTimeCategoryAxis is no linear.
For instance I was using :
var date = DateTime.FromOADate((double) cursor.X1);  //   with cursor typeof Syncfusion.UI.Xaml.Charts.VerticalLineAnnotation
var point = e.GetPosition(this.lineChart);  // with e typeof  MouseEventArgs
point.X = point.X - (yAxis.ActualWidth + lineChart.Margin.Left);
double xValue = lineChart.PointToValue(lineChart.PrimaryAxis, point);
var date =DateTime.FromOADate(xValue);   
What is the proper way to do such conversion with DateTimeCategoryAxis  ?

Prabakaran R [Syncfusion]
Replied On April 4, 2014 12:17 PM UTC

Hi Rodolphe,

Thanks for using the Syncfusion products.

We have analysed the reported requirement, and you cannot get the exact Datetime value in DateTimeCategoryAxis just by converting FromOADate since values positioned by category not linear, instead of you can get the nearest point value by using following code snippet, also we have prepared a sample based on this, please find it from the below link.

 Code snippet [C#]:

 private void SfChart_MouseDown(object sender, MouseButtonEventArgs e)


            var point = e.GetPosition(series);

            double x = 0d, y = 0d,stacked;

            series.FindNearestChartPoint(point, out x, out y, out stacked);

            var userProfile = series.ItemsSource as ObservableCollection<UserProfile>;//observable collection class where the data is set as items source for the series.

            MessageBox.Show(userProfile[(int)x].TimeStamp.ToString("MMM/dd/yyyy"));//display of datetime value where the mouse down event is clicked.


Please let us know if you require further assistance on this.



Attachment: DateTimeCategoryAxis_6d78e95a.zip


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