0
Microsoft.DataVisualization.Charting을 사용하고 클릭 할 때 값을 가져오고 싶습니다.마우스 클릭으로 계열 값 가져 오기
내 문제 : 정확히은 그 값이 Chart에서 계산 한 값이고 2 점 사이 인 경우에도 마찬가지입니다.
예 : 3 점 : P (0, 3), P (1, 6), P (3, 12)
난 곳을 클릭
x 값이 나는 경우 결과 9 싶어 선은 선형입니다. HitTestResult[] hits = chart.HitTest(e.X, e.Y, false, ChartElementType.PlottingArea);
//DataInformation save the DateTime and Value for later use
DataInformation[] dinfo = new DataInformation[hits.Length];
foreach (ChartArea area in chart.ChartAreas)
{
area.CursorX.LineWidth = 0; //clear old lines
}
for (int i = 0; i < hits.Length; i++) //for all hits
{
if (hits[i].ChartElementType == ChartElementType.PlottingArea)
{
//val saves the x-value clicked in the ChartArea
double val = hits[i].ChartArea.AxisX.PixelPositionToValue(e.X);
DataPoint pt = chart.Series[hits[i].ChartArea.Name].Points.Last(elem => elem.XValue < val);
dinfo[i].caption = hits[i].ChartArea.Name;
dinfo[i].value = pt.YValues[0].ToString();
//hits[i].ChartArea.CursorX.Position = pt.XValue;
}
}
이 모든 기존 데이터 포인트에 대한 올바른 값을 표시하지만 그 는 지점을 클릭 :
현재 내가 그렇게.
어떻게하면 정확한 값을 얻을 수 있습니까?