折线图设计基于HSL

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)
        {
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

锋利成

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值