先看效果

1.搭建页面
Chart 控件 timer button
Chart属性 Series => ChartType
- Cloumn 柱状图
- Point 点状图
- Area 面积图
- Pie 饼状图
- Candlestick 烛台形
- Radar 雷达
- Spline 线条曲线
Timer => Interval =>300
2. 实例化
cs
List<double>dataForChatDisp=new List<double>() { 3,1,4,5,9};
3.封装表格方法
cs
private void Disp_charts()
{
chart1.Series[0].Points.DataBindY(dataForChatDisp);
chart2.Series[0].Points.DataBindY(dataForChatDisp);
chart3.Series[0].Points.DataBindY(dataForChatDisp);
chart4.Series[0].Points.DataBindY(dataForChatDisp);
chart5.Series[0].Points.DataBindY(dataForChatDisp);
chart6.Series[0].Points.DataBindY(dataForChatDisp);
chart7.Series[0].Points.DataBindY(dataForChatDisp);
}
4.随机生成实例
cs
Random random = new Random();
double dataNext;
5.窗体加载
cs
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled=false;
Disp_charts();
}
6.计时器刻度
cs
private void timer1_Tick(object sender, EventArgs e)
{
dataNext = random.Next(10);
dataForChatDisp.RemoveAt(0);
dataForChatDisp.Add(dataNext);
Disp_charts();
}
7.按钮功能实现
cs
private void btnforchat_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
功能

cs
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;
namespace _04.ForChatDisp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<double>dataForChatDisp=new List<double>() { 3,1,4,5,9};
Random random = new Random();
double dataNext;
private void Disp_charts()
{
chart1.Series[0].Points.DataBindY(dataForChatDisp);
chart2.Series[0].Points.DataBindY(dataForChatDisp);
chart3.Series[0].Points.DataBindY(dataForChatDisp);
chart4.Series[0].Points.DataBindY(dataForChatDisp);
chart5.Series[0].Points.DataBindY(dataForChatDisp);
chart6.Series[0].Points.DataBindY(dataForChatDisp);
chart7.Series[0].Points.DataBindY(dataForChatDisp);
}
private void timer1_Tick(object sender, EventArgs e)
{
dataNext = random.Next(10);
dataForChatDisp.RemoveAt(0);
dataForChatDisp.Add(dataNext);
Disp_charts();
}
private void btnforchat_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled=false;
Disp_charts();
}
}
}