C# ZedGraph实时多条曲线数据更新


C# ZedGraph实时多条曲线数据更新实例 具体 可以参考https://www.cnblogs.com/JiYF/p/11182658.html这里去查看效果 主要代码已说明,看懂就不要下载了,没有积分博客留言,给出邮箱,我给你发。
资源截图
代码片段和文件信息
using DataGridViewLinesDemo.Headle;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using ZedGraph;

namespace DataGridViewLinesDemo
{
    public partial class FromMain : Form
    {
        public FromMain()
        {
            InitializeComponent();
            this.lines = new List();
        }
        ~FromMain()
        {
            this.isSampling = false;
        }


        private List lines;   //所有的曲线
        private int tickStart = 0;     // 起始时间以毫秒为单位
        private DataReadyEventHandler onDataReady; 


        public event DataReadyEventHandler DataReady
        {
            add { this.onDataReady += value; }
            remove { this.onDataReady -= value; }
        }

       
        //开始 停止采集 //初始化曲线
        private bool isSampling = false;
        private bool stop = true;
        private void btnLinesClick(object sender EventArgs e)
        {

            //加载创建曲线数据
            LineChannel lineChannel1 = new LineChannel(1111 1 “曲线 1“ “温度“ true Color.Red 1);
            LineChannel lineChannel2 = new LineChannel(2222 2 “曲线 2“ “温度“ true Color.Green 1);
            LineChannel lineChannel3 = new LineChannel(3333 3 “曲线 3“ “温度“ true Color.Gray 1);
            LineChannel lineChannel4 = new LineChannel(4444 4 “曲线 4“ “温度“ true Color.Black 1);

            this.lines.Add(lineChannel1);
            this.lines.Add(lineChannel2);
            this.lines.Add(lineChannel3);
            this.lines.Add(lineChannel4);


            //获取引用
            GraphPane myPane = zedGraphControl1.GraphPane;
            //设置标题
            myPane.title.Text = “实时曲线“;
            //设置X轴说明文字
            myPane.XAxis.title.Text = “时间“;
            //设置Y轴说明文字
            myPane.YAxis.title.Text = “温度“;


            //添加曲线
            foreach (LineChannel channel in this.lines)
            {
                RollingPointPairList list = new RollingPointPairList(1200);
                LineItem curve = myPane.AddCurve(channel.Name list channel.LineColor SymbolType.None);
            }


            int increment = 30;//单位s




            myPane.XAxis.Scale.Min = 0; //X轴最小值0
            myPane.XAxis.Scale.Max = 30; //X轴最大30
            myPane.XAxis.Scale.MinorStep = 1;//X轴小步长1也就是小间隔
            myPane.XAxis.Scale.MajorStep = 5;//X轴大步长为5,也就是显示文字的大间隔

            //改变轴的刻度
            zedGraphControl1.AxisChange();
            this.zedGraphControl1.Invalidate();
            this.dataGridViewLines.DataSource = this.lines;
            this.dataGridViewLines.ClearSelection();
        }
        private void btnStart_Click(object sender EventArgs e)
        {
            //timeDraw.Interval = 50; //设置timer控件的间隔为50毫秒
            //timeDraw.Enabled = true; //timer可用
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      22016  2019-07-13 23:17  DataGridViewLinesDemoinDebugDataGridViewLinesDemo.exe

     文件      54784  2019-07-13 23:17  DataGridViewLinesDemoinDebugDataGridViewLinesDemo.pdb

     文件      24216  2019-07-13 22:54  DataGridViewLinesDemoinDebugDataGridViewLinesDemo.vshost.exe

     文件        490  2016-07-16 19:44  DataGridViewLinesDemoinDebugDataGridViewLinesDemo.vshost.exe.manifest

     文件     290304  2019-07-11 13:42  DataGridViewLinesDemoinDebugedGraph.dll

     文件    1494558  2019-07-11 13:42  DataGridViewLinesDemoinDebugedGraph.xml

     文件       4096  2019-07-11 13:42  DataGridViewLinesDemoinDebugzh-cnedGraph.resources.dll

     文件       3836  2019-07-11 23:31  DataGridViewLinesDemoDataGridViewLinesDemo.csproj

     文件      12816  2019-07-13 23:16  DataGridViewLinesDemoFromMain.cs

     文件      14480  2019-07-13 22:50  DataGridViewLinesDemoFromMain.Designer.cs

     文件       6226  2019-07-13 22:50  DataGridViewLinesDemoFromMain.resx

     文件        565  2019-07-11 23:10  DataGridViewLinesDemoHeadleDataReadyEventArgs.cs

     文件        227  2019-07-11 22:57  DataGridViewLinesDemoHeadleDataReadyEventHandler.cs

     文件       2050  2019-07-11 23:45  DataGridViewLinesDemoHeadleLineData.cs

     文件       1714  2019-07-13 22:44  DataGridViewLinesDemoLineChannel.cs

     文件          0  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csproj.CopyComplete

     文件         42  2019-07-13 23:13  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csproj.CoreCompileInputs.cache

     文件       4752  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csproj.FileListAbsolute.txt

     文件       1015  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csproj.GenerateResource.cache

     文件      37067  2019-07-13 23:13  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csprojAssemblyReference.cache

     文件       7972  2019-07-13 17:47  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.csprojResolveAssemblyReference.cache

     文件      22016  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.exe

     文件        180  2019-07-13 22:50  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.FromMain.resources

     文件      54784  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.pdb

     文件        180  2019-07-13 17:47  DataGridViewLinesDemoobjDebugDataGridViewLinesDemo.Properties.Resources.resources

     文件      28486  2019-07-13 23:17  DataGridViewLinesDemoobjDebugDesignTimeResolveAssemblyReferences.cache

     文件       7265  2019-07-13 23:13  DataGridViewLinesDemoobjDebugDesignTimeResolveAssemblyReferencesInput.cache

     文件        505  2019-07-11 20:18  DataGridViewLinesDemoProgram.cs

     文件       1358  2019-07-11 20:17  DataGridViewLinesDemoPropertiesAssemblyInfo.cs

     文件        615  2019-07-11 22:25  DataGridViewLinesDemoPropertiesDataSourcesLineChannel.datasource

............此处省略29个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)