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
725
How to get the x and y axis values in a DataChart_MouseMove event?
posted

Hi to All,

In a DataChart_MouseMove event I got the MouseEventArgs. Now I would like to calculate the X and Y axis values.

I do not know it matters or not but I have multiple axes, 2 X NumericAxes and 2 Y NumericAxes.


Thanks in advance.

Parents
No Data
Reply
  • 34830
    Verified Answer
    Offline posted

    Hello Justin,

    To obtain the X and Y Axis values in the MouseMove event of the XamDataChart, I would recommend first to get the first or default series from the XamDataChart by calling XamDataChart1.Series.FirstOrDefault() and setting this to a var variable. If that series is not equal to null, you can continue. Note that the series doesn’t really need to have anything in it, it just needs to be there.

    After obtaining the first series, you can get the position of the mouse relative to it by calling e.GetPosition(series). Since you have two of each X and Y Numeric axis, you will need to obtain all of them after that by calling XamDataChart1.Axes[axis-index]. Then, you can calculate the viewport and the window size, which will be used in the scaling parameters later. You can get the viewport by setting it to a new Rect at (0, 0, xAxis.ActualWidth, yAxis.ActualHeight); and you can get the window by calling XamDataChart1.WindowRect;

    From there, you can set Scaler Parameters to scale your values relative to something. In the parameters you pass in the window and the viewport. From there, you can use XAxis.GetUnscaledValue(MousePosition.X, ScaledParameters) to get the position on the axis.

    I have attached a sample application that uses two numeric x and y axes to demonstrate the above.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Developer Support Engineer I
    Infragistics Inc.
    www.infragistics.com/support

    XamDataChartXYAxisValuesCase.zip
Children
No Data