设为首页 加入收藏

TOP

WInforn中设置ZedGraph的焦点显示坐标格式化以及显示三个坐标数的解决办法
2019-10-09 20:05:53 】 浏览:233
Tags:WInforn 设置 ZedGraph 焦点 显示 坐标 格式 以及 三个 解决 办法

场景

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();
        }

 

效果

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Winform中设置ZedGraph的曲线为折.. 下一篇abp(net core)+easyui+efcore实现..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目