hsl不收费的话感觉是一个很好的东西
1.下个hsl包 ![hsl包](https://img-blog.csdnimg.cn/62a56ce4ec3b4a8eaf1a1272d49f663a.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6ZSL5Yip5oiQ,size_20,color_FFFFFF,t_70,g_se,x_16)
2.设计个界面 ![界面控件](https://img-blog.csdnimg.cn/e3dd6ddbfc784c09a20c70a4c97e7c38.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6ZSL5Yip5oiQ,size_20,color_FFFFFF,t_70,g_se,x_16)
3.效果
![在这里插入图片描述](https://img-blog.csdnimg.cn/2c847af390634efba9d58ae986d32015.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6ZSL5Yip5oiQ,size_20,color_FFFFFF,t_70,g_se,x_16)
4.程序(方法中写入三个值生成折线图)
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 自动折线图
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int count;
float min;
float max;
private void Button1_Click(object sender, EventArgs e)
{
hslCurveHistory1.SetLeftCurve("A", GetRandomValueByCount(10, 0, 200), Color.DodgerBlue);
hslCurveHistory1.SetLeftCurve("B", GetRandomValueByCount(10, 0, 200), Color.Tomato);
hslCurveHistory1.SetLeftCurve("C", GetRandomValueByCount(10, 0, 200), Color.Green);
}
private float[] GetRandomValueByCount(int count, float min, float max)
{
//堆上开辟一个数量空间,需要指定长度
float[] data = new float[count];
for (int i = 0; i < data.Length; i++)
{
data[i] = (float)random.NextDouble() * (max - min) + min;
}
return data;
}
private Random random = new Random();
private void Button2_Click_1(object sender, EventArgs e)
{
//hslCurveHistory1.RemoveCurve("A"); // 移除指定的曲线
hslCurveHistory1.RemoveAllCurve(); // 移除所有的曲线
// 这里传入了数组长度为空的数据,不能传NULL
hslCurveHistory1.SetLeftCurve("D", new float[] { }, Color.Tomato); // 指定上限500个数据,该上限只对拉伸模式有效
//移除标定线
hslCurveHistory1.RemoveAuxiliary(100);
}
private void Form1_Load(object sender, EventArgs e)
{
string[] text = new string[]
{
"10个","20个","30个","40个","50个", "60个","70个","80个","90个","100个"
};
hslCurveHistory1.SetCurveText(text);
}
private void Button3_Click(object sender, EventArgs e)
{
Timer timer = new Timer();
timer.Interval = 1000;
timer.Tick += (sender1, e1) =>
{
hslCurveHistory1.SetLeftCurve("A", GetRandomValueByCount(10, 0, 200), Color.DodgerBlue);
hslCurveHistory1.SetLeftCurve("B", GetRandomValueByCount(10, 0, 200), Color.Tomato);
hslCurveHistory1.SetLeftCurve("C", GetRandomValueByCount(10, 0, 200), Color.Green);
hslCurveHistory1.AddLeftAuxiliary(100, Color.Red);
};
timer.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
}
}