Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
CategoryXAxis mouse click event date/time conversion
posted

 I am trying to convert mouse event args to a date/time from the categoryXAxis.  When I tried to convert the x value to dateTime, it is setting the year (in all instances), to 1900. 

 

Point position = e.GetPosition(s);

LineSeries ls = s as LineSeries;

CategoryXAxis x = ls.XAxis as CategoryXAxis;

NumericYAxis y = ls.YAxis;

Rect viewport = new Rect(0, 0, x.ActualWidth, y.ActualHeight);

Rect window = s.SeriesViewer.WindowRect;

bool isInverted = x.IsInverted;

ScalerParams param = new ScalerParams(window, viewport, isInverted);

var unscaledX = x.GetUnscaledValue(position.X, param);

isInverted = y.IsInverted;

param = new ScalerParams(window, viewport, isInverted);

var unscaledY = y.GetUnscaledValue(position.Y, param);

DateTime xValue = DateTime.FromOADate(unscaledX);

double yValue = Convert.ToDouble(unscaledY);