Chart中提供了 DataIndexFromPoint 方法可以使用:
- _ddManager.DragDrop += (s, e) =>
- {
- DataSeries dser = ((PlotElement)e.DragSource).DataPoint.Series;
- DataPoint ds = ((PlotElement)e.DragSource).DataPoint;
- PlotElement pe = (PlotElement)e.DragSource;
- pe.Fill = CreateBrush(Colors.Red);
- Point pt = e.GetPosition(chart2);
- //MessageBox.Show("X:" + this.txtX.Text + " Y:" + this.txtY.Text);
-
- double dis;
- int x = chart2.View.DataIndexFromPoint(e.GetPosition(this), 0, MeasureOption.X, out dis);
- int y = chart2.View.DataIndexFromPoint(e.GetPosition(this), 0, MeasureOption.Y, out dis);
- MessageBox.Show("X:" + x + " Y:" + y);
- };
复制代码 |