C#中利用LightningChart绘制曲线图表
最近在做一个“基于C#语言的电炉温控制软件设计”的设计,我在大学并不是专业学习C#语言编程的,对C#的学习研究完全是处于兴趣,所以编程技术也不是很厉害,遇到问题多参照网络上的开源码。
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 Arction.WinForms.Charting;
using Arction.WinForms.Charting.SeriesXY;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//画线方法
private void PaintLine()
{
DataBaseOpe ope = new DataBaseOpe();
//禁用属性改变引起的重画,以便更快的渲染
lightningChartUltimate1.BeginUpdate();
//lightningChartUltimate1.Dock = DockStyle.Fill;
//添加点线系列
PointLineSeries pls = new PointLineSeries(lightningChartUltimate1.ViewXY,
lightningChartUltimate1.ViewXY.XAxes[0],
lightningChartUltimate1.ViewXY.YAxes[0]);
//显示点
pls.PointsVisible = false;
SeriesPoint[] aPoints = new SeriesPoint[1000];
for (int iPoint = 0; iPoint < ope.GetXmax() + 1; iPoint++)
{
aPoints[iPoint].X = (double)iPoint;
aPoints[iPoint].Y = ope.GetYvalue(iPoint);
}
//为点线系列分配数据
pls.Points = aPoints;
//将点线系列添加进列表
lightningChartUltimate1.ViewXY.PointLineSeries.Add(pls);
//允许Chart绘图
lightningChartUltimate1.EndUpdate();
}
private void buttonGO_Click(object sender, EventArgs e)
{
DataBaseOpe ope = new DataBaseOpe();
PIDdeal pid = new PIDdeal();
//LightningChart初始化
lightningChartUltimate1.ViewXY.PointLineSeries.Clear();
//数据库初始化:清空数据库
ope.ClearDataBase();
//PID变量初始化
pid.PIDinit();
pid.SetValue = double.Parse(textBoxSetValue.Text);
double p = double.Parse(textBoxKp.Text);
double i = double.Parse(textBoxKi.Text);
double d = double.Parse(textBoxKd.Text);
for(int j = 0;j < 1000;j++)
{
ope.AddData(j, pid.PIDcontrol(pid.SetValue, p, i, d));
}
PaintLine();
}
}
}
https://download.csdn.net/download/zpkld123/10309584