C# Chart 点击获取当前点击坐标和Series
https://blog.csdn.net/wumuzhizi/article/details/47168989
开发需要获取当前点击Chart的坐标和Series 的Name,label,找了半天才找到啊
在Click或者Mouse的click事件中添加
-
System.Windows.Forms.DataVisualization.Charting.HitTestResult Result = new System.Windows.Forms.DataVisualization.Charting.HitTestResult();
-
Result = chart1.HitTest(e.X, e.Y);
-
if(Result.Series!=null)
-
MessageBox.Show("'X轴:'" + Result.Series.Points[Result.PointIndex].XValue.ToString() + <span style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; white-space: nowrap;">"'Y轴:'" + Result.Series.Points[Result.PointIndex].YValues[0].ToString());</span>
Result.Series 就是点击获得的Series
Result.Series.Points[Result.PointIndex].XValue 为点击Series X坐标
Result.Series.Points[Result.PointIndex].YValue 为点击Series Y坐标