简体   繁体   中英

OxyPlot get clicked Position in PlotView/PlotModel

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?

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 ... 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM