C#中利用LightningChart绘制曲线图表
2021-04-19 17:27
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 {
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 {
ope.AddData(j, pid.PIDcontrol(pid.SetValue, p, i, d));
}
PaintLine();
}
}
}
https://download.csdn.net/download/zpkld123/10309584
上一篇:.Net 动态编译(c# 脚本)
下一篇:C# 关键字extern用法
文章标题:C#中利用LightningChart绘制曲线图表
文章链接:http://soscw.com/index.php/essay/76755.html