0
点赞
收藏
分享

微信扫一扫

WInforn中设置ZedGraph的焦点显示坐标格式化以及显示三个坐标数的解决办法


场景


ZedGraph设置显示坐标值

zgc.IsShowCursorValues = true;

但是在刷新曲线图之后出现了鼠标焦点出现三个坐标值

WInforn中设置ZedGraph的焦点显示坐标格式化以及显示三个坐标数的解决办法_公众号

 

解决方法是在其鼠标焦点悬浮事件中格式化其要显示的值,修改为举例最近的去曲线上的点。

注:

实现

//显示焦点值事件
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();
}

效果

WInforn中设置ZedGraph的焦点显示坐标格式化以及显示三个坐标数的解决办法_公众号_02

 

举报

相关推荐

0 条评论