方法一:鼠标点击波形

鼠标点击波形,显示点击位置的x,y值

private void chart1_mouseclick(object sender, mouseeventargs e)  //chart1是你建的chart控件,实际名字根据你自己代码里的命名
        {            
            hittestresult hit = chart1.hittest(e.x, e.y);
            if (hit.series != null)
            {
                var xvalue = hit.series.points[hit.pointindex].xvalue;
                var yvalue = hit.series.points[hit.pointindex].yvalues.first();
                textbox1.text = string.format(“{0:f0},{1:f0}”, “x:”+xvalue, “y:”+yvalue);//textbox1也是自己建的一个专门用来显示的内容框,也可以用messagebox直接弹出内容
            }
            else
            {
                textbox1.text=”未点击到波形曲线”;
            }
        }

 

调用方法:

chart1.mouseclick += new mouseeventhandler(chart1_mouseclick);

 

方法二:鼠标移动到相应点位自动显示相关数值

private void chart1_mousemove(object sender, mouseeventargs e)
        {
            var area = chart1.chartareas[0];

            double xvalue = area.axisx.pixelpositiontovalue(e.x);
            double yvalue = area.axisy.pixelpositiontovalue(e.y);
            textbox1.text = string.format(“{0:f0},{1:f0}”, xvalue, yvalue);
        }

调用方法:

chart1.mousemove += new mouseeventhandler(chart1_mousemove);