C#ChartコントロールX軸と複数のY軸座標値取得例


X軸表示時間は、Y軸に2つの変数表示があり、同時にY軸の2つの変数値を取得し、フォームのtextboxに値を表示します.
private void chart1_GetToolTipText(object sender, ToolTipEventArgs e)
        {
            HitTestResult myTestResult = chart1.HitTest(e.X, e.Y, ChartElementType.DataPoint);// 
            if (myTestResult.ChartElementType == ChartElementType.DataPoint)
            {
                try
                {
                    int i = myTestResult.PointIndex;
                    // 
                    DataPoint dp = myTestResult.Series.Points[i];
                    DateTime pointDateTime = DateTime.FromOADate(dp.XValue);
                    DataPoint dp1 = chart1.Series[0].Points[i];
                    DataPoint dp2 = chart1.Series[1].Points[i];
                    string YValue1 = dp1.YValues[0].ToString("0.0");
                    string YValue2 = dp2.YValues[0].ToString("0.0");
                    txtT.Text = YValue1;
                    txtH.Text = YValue2;
                    txtTime.Text = pointDateTime.ToString("MM/dd HH:mm:ss");
                }
                catch { };
            }
        }