OxyPlot获得点击点 [英] OxyPlot get clicked point

查看:1262
本文介绍了OxyPlot获得点击点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过绘制出散点图某些圈子:

I am trying to plot some circles on a scatter plot via:

<Grid>
    <oxy:PlotView x:Name="PlotView" Title="{Binding Title}" >
        <oxy:PlotView.Axes>
            <oxy:LinearAxis Position="Bottom" Minimum="-30" Maximum="30" IsAxisVisible="False" IsZoomEnabled="False" IsPanEnabled="False" />
            <oxy:LinearAxis Position="Left" Minimum="0" Maximum="35" IsAxisVisible="False" IsZoomEnabled="False" IsPanEnabled="False"/>
        </oxy:PlotView.Axes>
        <oxy:PlotView.Series>
            <oxy:ScatterSeries Height="100" Width="100" ItemsSource="{Binding Points}" MarkerType="Circle" />
        </oxy:PlotView.Series>
    </oxy:PlotView>
</Grid>



我无法弄清楚如何启用某种点击处理程序有一个触发的事件,当用户。点击一个数据点

I can not figure out how to enable some sort of click handler to have an event fired when a user clicks on a DataPoint.

〔实施例:

用户点击数据点在X:0,Y:5,我想触发一个事件,所以我可以处理该点的点击。

User clicks datapoint at X: 0, Y: 5, I would like to fire an event so I can handle the click of that point.

这可能与OxyPlot?我目前正在调查追踪,看看它可能的路线,但开始江郎才尽了。

Is this possible with OxyPlot? I am currently investigating the Tracker to see if its possible that route, but starting to run out of ideas.

推荐答案

PlotView 定义鼠标事件,从中可以得到鼠标的坐标。和 InverseTransform 用于转换鼠标坐标绘制坐标

PlotView has defined Mouse events, from which you can get the mouse coordinates. And InverseTransform is used to translate mouse coordinates to plot coordinates.

例如:

var model = new PlotModel { Title = "Test Mouse Events" };

var s1 = new LineSeries();
model.Series.Add(s1);

double x;

s1.MouseDown += (s, e) =>
    {
        x = (s as LineSeries).InverseTransform(e.Position).X;
    };

这篇关于OxyPlot获得点击点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆