4

I'm trying to get the clicked position in my PlotView or PlotModel. But I just get some window-screen points not concerning any values in my PlotModel.

The question OxyPlot get clicked point is about clicking on LineSeries, not in any poisition of my plot.

Any ideas?

1 Answer 1

8

Use InverseTransformation with your MouseEvent.Position and your axis.

private void MyPlotModel_MouseDown(object sender, OxyMouseDownEventArgs ex)
{
    OxyPlot.ElementCollection<OxyPlot.Axes.Axis> axisList = MyPlotModel.Axes;

    Axis xAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Bottom);
    Axis yAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Left);

    DataPoint dataPointp = OxyPlot.Axes.Axis.InverseTransform(ex.Position, xAxis, yAxis);

    // Do stuff with dataPointp ... 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.