How to get the X coordinate when you click on the graph in c #, the Chart component.
2 answers
Method Chart.HitTest to help you.
Defines a chart element, if any, located at a point that is defined by given X and Y coordinates. For more details, refer to the official documentation at the link above.
Well, for demonstration, here's a handler that returns the Y value of the point to which it was clicked.
private void chart1_MouseClick(object sender, MouseEventArgs e) { var res = chart1.HitTest(eX, eY); if(res.Series != null) MessageBox.Show(res.Series.Points[res.PointIndex].YValues[0].ToString()); } |
Event MouseClick eX property
- Get the cursor coordinates relative to the left side of the Chart component, but not the coordinates of a point on the chart - slippyk
- @slippyk, so the vehicle did not say that it is necessary to coordinate on the graph. - iRumba
- need exactly the coordinate on the graph - Alexandr Samodurov
|