HitTestResult result = chart1.HitTest(e.X, e.Y);
if (result.ChartElementType == ChartElementType.DataPoint)
{
DataPoint selectedDataPoint = (DataPoint)result.Object;
//MessageBox.Show("X 值:" + selectedDataPoint.XValue + " Y 值: " + selectedDataPoint.YValues[0]);
MessageBox.Show("X 值:" + selectedDataPoint.AxisLabel + " Y 值: " + selectedDataPoint.YValues[0]);
}
else if (result.ChartElementType != ChartElementType.Nothing)
{
string elementType = result.ChartElementType.ToString();
MessageBox.Show(this, "Selected Element is: " + elementType);
}
----------------------------------------------------------------------------------------------------------------AxisLabel 因为X轴上没有值,只有Y轴上有值,所以这里直接取X轴的量测项(WINFORM)。
WEBFORM用webback就很好实现,在此不叙述。网上大把人的建议都是瞎扯蛋,根本是浪费时间。