• 大小: 111KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-06
  • 语言: C#
  • 标签: C#  chart  trend  realtime  

资源简介

c#编写的实时趋势示例,使用visual studio自带的chart,定时器实时绘制趋势,可以手动设置纵坐标上下限,也可根据数据实时值自动设置纵坐标上下限。

资源截图

代码片段和文件信息

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 WindowsFormsApplication1
{
    public partial class Form6 : Form
    {
        public Form6()
        {
            InitializeComponent();
        }

        public void CreateYAxis(Chart chart ChartArea area Series series float axisOffset float labelsSize)
        {
            // Create new chart area for original series
            ChartArea areaSeries = chart.ChartAreas.Add(“ChartArea_“ + series.Name);
            areaSeries.BackColor = Color.Transparent;
            areaSeries.BorderColor = Color.Transparent;
            areaSeries.Position.FromRectangleF(area.Position.ToRectangleF());
            areaSeries.InnerPlotPosition.FromRectangleF(area.InnerPlotPosition.ToRectangleF());
            areaSeries.AxisX.MajorGrid.Enabled = false;
            areaSeries.AxisX.MajorTickMark.Enabled = false;
            areaSeries.AxisX.Labelstyle.Enabled = false;
            areaSeries.AxisY.MajorGrid.Enabled = false;
            areaSeries.AxisY.MajorTickMark.Enabled = false;
            areaSeries.AxisY.Labelstyle.Enabled = false;
            areaSeries.AxisY.IsStartedFromZero = area.AxisY.IsStartedFromZero;
            areaSeries.AxisY.LineColor = Color.Red;
            
            series.ChartArea = areaSeries.Name;

            /*
            // Create new chart area for axis
            ChartArea areaAxis = chart.ChartAreas.Add(“AxisY_“ + series.ChartArea);
            areaAxis.BackColor = Color.Transparent;
            areaAxis.BorderColor = Color.Transparent;
            areaAxis.Position.FromRectangleF(chart.ChartAreas[series.ChartArea].Position.ToRectangleF());
            areaAxis.InnerPlotPosition.FromRectangleF(chart.ChartAreas[series.ChartArea].InnerPlotPosition.ToRectangleF());
            areaAxis.AxisY.LineColor = Color.Red;
            areaAxis.AxisY.MajorTickMark.LineColor = Color.Red;

            
            // Create a copy of specified series
            Series seriesCopy = chart.Series.Add(series.Name + “_Copy“);
            seriesCopy.ChartType = series.ChartType;
            foreach (DataPoint point in series.Points)
            {
                seriesCopy.Points.AddXY(point.XValue point.YValues[0]);
            }
            
            // Hide copied series
            seriesCopy.IsVisibleInLegend = false;
            seriesCopy.Color = Color.Transparent;
            seriesCopy.BorderColor = Color.Transparent;
            seriesCopy.ChartArea = areaAxis.Name;  
             

            // Disable drid lines & tickmarks
            areaAxis.AxisX.LineWidth = 0;
            areaAxis.AxisX.MajorGrid.Enabled = false;
            areaAxis.AxisX.MajorTickMark.Enabled = false;
    

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

     文件        962  2017-06-20 10:32  WindowsFormsApplication1.sln

     文件        167  2018-05-23 17:22  WindowsFormsApplication1\App.config

     文件      15872  2018-05-23 17:24  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件        167  2018-05-23 17:22  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config

     文件      26112  2018-05-23 17:24  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      22472  2018-05-23 17:23  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        167  2018-05-23 17:22  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config

     文件        490  2017-09-29 21:43  WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       9068  2018-05-23 17:24  WindowsFormsApplication1\Form6.cs

     文件      11775  2018-05-23 17:24  WindowsFormsApplication1\Form6.Designer.cs

     文件       6011  2018-05-23 17:24  WindowsFormsApplication1\Form6.resx

     文件      40588  2017-12-05 23:46  WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7508  2018-05-23 17:22  WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2017-06-20 10:32  WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2017-06-20 10:32  WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2017-06-20 10:32  WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       4608  2018-05-23 17:23  WindowsFormsApplication1\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       7472  2018-05-23 17:24  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        975  2018-05-23 17:24  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件        686  2018-05-23 17:24  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.ResolveComReference.cache

     文件      15872  2018-05-23 17:24  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form2.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form3.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form4.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form5.resources

     文件        180  2018-05-23 17:24  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form6.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form7.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.frmContour.resources

     文件        180  2018-05-23 17:19  WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.frmProcess.resources

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

评论

共有 条评论