资源简介
C#中以时间作为chart的X坐标轴间隔,波形图chart的X轴坐标为时间(ms),

代码片段和文件信息
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; //与chart相关的引用
using System.Threading;
namespace testChartWithTime
{
public partial class Form1 : Form
{
private DateTime minValue maxValue; //横坐标最小和最大值
private Random rand = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
minValue = DateTime.Now; //x轴最小刻度
maxValue = minValue.AddSeconds(1); //X轴最大刻度比最小刻度大1秒
chart1.ChartAreas[0].AxisX.Labelstyle.Format = “HH:mm:ss.fff“; //毫秒格式: hh:mm:ss.fff ,后面几个f则保留几位毫秒小数,此时要注意轴的最大值和最小值不要差太大
chart1.ChartAreas[0].AxisX.Labelstyle.IntervalType = DateTimeIntervalType.Milliseconds;
chart1.ChartAreas[0].AxisX.Labelstyle.Interval = 200; //坐标值间隔200 ms
chart1.ChartAreas[0].AxisX.Labelstyle.IsEndLabelVisible = false; //防止X轴坐标跳跃
chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Milliseconds;
chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 200;
chart1.ChartAreas[0].AxisX.Minimum = minValue.ToOADate();
chart1.ChartAreas[0].AxisX.Maximum = maxValue.ToOADate();
chart1.Series.Clear();
Series newSeries = new Series(“Series1“);
newSeries.ChartType = SeriesChartType.Line;
newSeries.BorderWidth = 1;
newSeries.Color = Color.FromArgb(0 0 255);
newSeries.XValueType = ChartValueType.DateTime;
chart1.Series.Add(newSeries);
timer1.Interval = 200;
chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate() 10);
Thread.Sleep(200);
chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate() 5);
Thread.Sleep(200);
chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate() 15);
Thread.Sleep(200);
chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate() 10);
Thread.Sleep(1000);
chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate() 15);
Thread.Sleep(100);
chart1.ChartAreas[0].AxisX.Maximum = DateTime.Now.ToOADate();
}
public void AddNewPoint(DateTime timeStamp System.Windows.Forms.DataVisualization.Charting.Series ptSeries)
{
// Add new data point to its series.
ptSeries.Points.AddXY(timeStamp.ToOADate() rand.Next(5 20));
// remove all points from the source series older than 1 seconds.
double removeBefore = timeStamp.AddSeconds((double)(1) * (-1)).ToOADate();
//remove oldest valu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 18944 2018-09-20 09:51 testChartWithTime\testChartWithTime\bin\Debug\testChartWithTime.exe
文件 30208 2018-09-20 09:51 testChartWithTime\testChartWithTime\bin\Debug\testChartWithTime.pdb
文件 11600 2018-09-21 08:52 testChartWithTime\testChartWithTime\bin\Debug\testChartWithTime.vshost.exe
文件 490 2010-03-17 22:39 testChartWithTime\testChartWithTime\bin\Debug\testChartWithTime.vshost.exe.manifest
文件 4188 2018-09-20 10:18 testChartWithTime\testChartWithTime\Form1.cs
文件 4869 2018-09-20 09:50 testChartWithTime\testChartWithTime\Form1.Designer.cs
文件 6184 2018-09-20 09:50 testChartWithTime\testChartWithTime\Form1.resx
文件 6272 2018-09-20 15:00 testChartWithTime\testChartWithTime\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6638 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 88576 2018-08-23 10:51 testChartWithTime\testChartWithTime\obj\x86\Debug\Interop.ADODB.dll
文件 23040 2018-08-23 10:51 testChartWithTime\testChartWithTime\obj\x86\Debug\Interop.ADOX.dll
文件 1881 2018-09-21 08:52 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.csproj.FileListAbsolute.txt
文件 975 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.csproj.GenerateResource.Cache
文件 835 2018-08-23 10:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.csproj.ResolveComReference.cache
文件 18944 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.exe
文件 180 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.Form1.resources
文件 30208 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.pdb
文件 180 2018-09-20 09:51 testChartWithTime\testChartWithTime\obj\x86\Debug\testChartWithTime.Properties.Resources.resources
文件 498 2018-08-23 09:24 testChartWithTime\testChartWithTime\Program.cs
文件 1384 2018-08-23 09:24 testChartWithTime\testChartWithTime\Properties\AssemblyInfo.cs
文件 2886 2018-08-23 09:24 testChartWithTime\testChartWithTime\Properties\Resources.Designer.cs
文件 5612 2018-08-23 09:24 testChartWithTime\testChartWithTime\Properties\Resources.resx
文件 1104 2018-08-23 09:24 testChartWithTime\testChartWithTime\Properties\Settings.Designer.cs
文件 249 2018-08-23 09:24 testChartWithTime\testChartWithTime\Properties\Settings.settings
文件 7828 2018-08-23 10:51 testChartWithTime\testChartWithTime\saveAccessFile.cs
文件 4516 2018-09-20 09:51 testChartWithTime\testChartWithTime\testChartWithTime.csproj
文件 893 2018-08-23 09:24 testChartWithTime\testChartWithTime.sln
..A..H. 53248 2018-09-21 08:52 testChartWithTime\testChartWithTime.suo
目录 0 2018-08-23 09:24 testChartWithTime\testChartWithTime\obj\x86\Debug\TempPE
目录 0 2018-09-20 15:00 testChartWithTime\testChartWithTime\obj\x86\Debug
............此处省略10个文件信息
相关资源
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论