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
1105
Get clicked data point or axis position otherwise
posted

Hi.

I'm have a chart showing points over time using CategoryDateTimeXAxis.

I want to get the following behavior:

if user click on a series data point, the application should identify that and do something (let's say show a message box with the x and y values)

else show the y value, converted to datetime.

I have the following code that give me the y value based on the axis, but how can I get the first request also?

private void timeline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     {
         MoveNavBar(e);
     }
 
     private void MoveNavBar(MouseEventArgs e)
     {
         if (e.LeftButton == MouseButtonState.Pressed)
         {
             var position = e.GetPosition(axisX);
 
             //we 
 
             var x = timeline.Axes.OfType<CategoryDateTimeXAxis>().First();
             var viewport = new Rect(0, 0, x.ActualWidth, 0);
             var window = timeline.WindowRect;
 
             ScalerParams sp = new ScalerParams(window, viewport, false);
             var unscaledX = x.GetUnscaledValue(position.X, sp);
             DateTime selectedTime = new DateTime((long)unscaledX);
 
             NavigationController.SetDate(selectedTime, this);
         }
     }