场景
Winforn中设置ZedGraph曲线图的属性、坐标轴属性、刻度属性:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100112573
Winform中实现ZedGraph的多条Y轴(附源码下载):
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100132245
ZedGraph设置显示坐标值
zgc.IsShowCursorValues = true;
但是在刷新曲线图之后出现了鼠标焦点出现三个坐标值
解决方法是在其鼠标焦点悬浮事件中格式化其要显示的值,修改为举例最近的去曲线上的点。
注:
博客主页:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
//显示焦点值事件 zgc.CursorValueEvent += zgc_CursorValueEvent;
然后在方法中
private static string zgc_CursorValueEvent(ZedGraphControl sender, GraphPane pane, Point mousePt) { CurveItem nearstCurve; int i; Double x = 0.0; Double y = 0.0; Global.zedGraphControl1.GraphPane.FindNearestPoint(mousePt, out nearstCurve, out i); if (nearstCurve!= null && nearstCurve.Points[i] != null && nearstCurve.Points[i].X != null) { x = nearstCurve.Points[i].X; } if (nearstCurve!= null && nearstCurve.Points[i] != null && nearstCurve.Points[i].Y != null) { y = nearstCurve.Points[i].Y; } return "X:" + x.ToString() + " Y:" + y.ToString(); }
效果