• 大小: 51KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: C#  多个表格  数据显示  

资源简介

C# Chart表格多个ChartArea、Series显示;滚动条ScrollBar随着数据的增加实时更新,显示区域始终在最右边

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace Chart_test1
{
    public partial class Form1 : Form
    {

        //Series m;
        //Series n;
        ///////////////////////
        private Queue dataQueue1 = new Queue(20);

        private Queue dataQueue2 = new Queue(20);

        private Queue dataQueue3 = new Queue(20);

        private Queue dataQueue4 = new Queue(20);

        private int curValue = 0;

        private int num = 1;
        ///////////////////////数据测试

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            UpdateQueueValue_chart1();
            UpdateQueueValue_chart2();
            UpdateQueueValue_chart3();
            this.timer1.Start();
            //jingjiexian();
            timer1.Enabled = false;
        }

        private void UpdateQueueValue_chart2()
        {
            Random r = new Random();
            for (int i = 0; i < num; i++)
            {
                dataQueue2.Enqueue(r.Next(-5 5));
            }

        }

        private void UpdateQueueValue_chart1()
        {
            Random r = new Random();
            for (int i = 0; i < num; i++)
            {
                //对curValue只取[0360]之间的值
                curValue = curValue % 360;
                //对得到的正玄值,放大50倍,并上移50
                dataQueue1.Enqueue((5 * Math.Sin(curValue * Math.PI / 180)) + 5);
                dataQueue4.Enqueue(r.Next(0 10));
                curValue = curValue + 10;
            }
        }

        private void UpdateQueueValue_chart3()//更新队列值
        {
            Random r = new Random();
            for (int i = 0; i < num; i++)
            {
                dataQueue3.Enqueue(r.Next(0 10));
            }
        }

        private void timer1_Tick(object sender EventArgs e)
        {
            UpdateQueueValue_chart1();//获取数据并储存
            UpdateQueueValue_chart2();
            UpdateQueueValue_chart3();

            this.chart1.Series[0].Points.Clear();//清除上一次画点
            this.chart1.Series[1].Points.Clear();
            this.chart1.Series[2].Points.Clear();
            this.chart1.Series[3].Points.Clear();

            Scrollbar_right();//滑块始终处于最右端,在前行测量时

            for (int i = 0; i < dataQueue1.Count; i++)
            {
                this.chart1.Series[0].Points.AddXY((i + 1) dataQueue1.ElementAt(i));//描点
                this.chart1.Series[1].Points.AddXY((i + 1) dataQueue4.ElementAt(i));
                this.chart1.Series[2].Points.AddXY((i + 1) dataQueue2.ElementAt(i));
                this.chart

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

     文件        189  2018-01-05 20:09  Chart_test1\App.config

     文件      14848  2018-01-07 17:02  Chart_test1\bin\Debug\Chart_test1.exe

     文件        189  2018-01-05 20:09  Chart_test1\bin\Debug\Chart_test1.exe.config

     文件      24064  2018-01-07 17:02  Chart_test1\bin\Debug\Chart_test1.pdb

     文件      22696  2018-01-07 17:02  Chart_test1\bin\Debug\Chart_test1.vshost.exe

     文件        189  2018-01-05 20:09  Chart_test1\bin\Debug\Chart_test1.vshost.exe.config

     文件        490  2017-03-19 05:00  Chart_test1\bin\Debug\Chart_test1.vshost.exe.manifest

     文件       3988  2018-01-05 20:38  Chart_test1\Chart_test1.csproj

     文件       5212  2018-01-07 17:02  Chart_test1\Form1.cs

     文件      14082  2018-01-07 16:47  Chart_test1\Form1.Designer.cs

     文件       6011  2018-01-07 16:47  Chart_test1\Form1.resx

     文件        843  2018-01-07 17:02  Chart_test1\obj\Debug\Chart_test1.csproj.FileListAbsolute.txt

     文件        976  2018-01-07 16:47  Chart_test1\obj\Debug\Chart_test1.csproj.GenerateResource.Cache

     文件       2559  2018-01-05 21:14  Chart_test1\obj\Debug\Chart_test1.csprojResolveAssemblyReference.cache

     文件      14848  2018-01-07 17:02  Chart_test1\obj\Debug\Chart_test1.exe

     文件        180  2018-01-07 16:47  Chart_test1\obj\Debug\Chart_test1.Form1.resources

     文件      24064  2018-01-07 17:02  Chart_test1\obj\Debug\Chart_test1.pdb

     文件        180  2018-01-05 20:38  Chart_test1\obj\Debug\Chart_test1.Properties.Resources.resources

     文件       1639  2018-01-07 16:42  Chart_test1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7304  2018-01-05 20:09  Chart_test1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2018-01-05 20:09  Chart_test1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2018-01-05 20:09  Chart_test1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2018-01-05 20:09  Chart_test1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        523  2018-01-05 20:09  Chart_test1\Program.cs

     文件       1330  2018-01-05 20:09  Chart_test1\Properties\AssemblyInfo.cs

     文件       2835  2018-01-05 20:09  Chart_test1\Properties\Resources.Designer.cs

     文件       5612  2018-01-05 20:09  Chart_test1\Properties\Resources.resx

     文件       1098  2018-01-05 20:09  Chart_test1\Properties\Settings.Designer.cs

     文件        249  2018-01-05 20:09  Chart_test1\Properties\Settings.settings

     目录          0  2018-01-05 20:09  Chart_test1\obj\Debug\TempPE

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

评论

共有 条评论