winform chart鼠标处显示mark

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

只需要在chart的GetToolTipText事件中增加下面的代码即可显示:

private void chart1_GetToolTipText(object sender, System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs e)
       {
           if (e.HitTestResult.ChartElementType == System.Windows.Forms.DataVisualization.Charting.ChartElementType.DataPoint)
           {
               int i = e.HitTestResult.PointIndex;
               System.Windows.Forms.DataVisualization.Charting.DataPoint dp = e.HitTestResult.Series.Points[i];
               e.Text = string.Format("({0:F3},{1:F3})", dp.XValue, dp.YValues[0]);
           }
       }

 

转载于:https://my.oschina.net/u/2963604/blog/2885225

你可能感兴趣的:(winform chart鼠标处显示mark)