2
我想知道如何获得(具体),只是我使用OxyPlot绘制的散点图的x坐标。从OxyPlot ScatterPlot获取数据点
//user clicks on graph line data...
//x-coordinate gets assigned to variable
int x = ...
我正在使用winforms。
编辑:
private void plotView_Click(object sender, EventArgs e){
plotView.ActualModel.Series[0].MouseDown += (s, e0) =>
{
if (e0.ChangedButton != OxyMouseButton.Left)
return;
else
pointx = (int)e0.HitTestResult.NearestHitPoint.X;
};
}
工作代码:
s0.MouseDown += (s, e0) =>
{
if (e0.ChangedButton == OxyMouseButton.Left)
{
var item = e0.HitTestResult.Item as ScatterPoint;
if (item != null)
{
pointx = (int)item.X;
}
}
};
虽然我需要在这个鼠标点击事件中,当我这样做时,我得到一个错误,说'e'不能在此范围内声明,因此我将它重命名为'e0'。当我这样做时,我总是得到一个零。我该如何解决? – John
也许试着让int x成为double值,这样它就不会将任何double值截断为0.除此之外,您可以编辑您的代码,我可以看看您正在做什么。 – Zachary
哦,如果你正在寻找点击的实际坐标(而不是像我可能假设的点),请执行:“e0.Position.X” – Zachary