C# + winform使用Scottplot快速入门创建第一个demo

Hello大家好我是开箱测评小汪

C# + winform使用Scottplot快速入门创建第一个demo_第1张图片

效果图

本次课程的要达到的目的:

1、 安装上scottplot控件

2、 创建第一个简单的scottplot demo程序

环境:

Visual Studio 2019 .net5.0

C# + winform使用Scottplot快速入门创建第一个demo_第2张图片

1、创建工程

C# + winform使用Scottplot快速入门创建第一个demo_第3张图片

2、使用Nuget 安装scottplot控件库

C# + winform使用Scottplot快速入门创建第一个demo_第4张图片

C# + winform使用Scottplot快速入门创建第一个demo_第5张图片

C# + winform使用Scottplot快速入门创建第一个demo_第6张图片

C# + winform使用Scottplot快速入门创建第一个demo_第7张图片

配置控件属性,使控件大小随窗口大小一起缩放

程序源码:

文件名:Form1.cs 

using ScottPlot;
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 Scottplot_01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var plt = formsPlot1.Plot;

            // sample data
            //X轴数据
            double[] xs = DataGen.Consecutive(51);

            //Y轴数据
            double[] sin = DataGen.Sin(51);
            double[] cos = DataGen.Cos(51);

            // 2条曲线
            plt.AddScatter(xs, sin);
            plt.AddScatter(xs, cos);

            // plot参数设置
            plt.Title("标题");
            plt.XLabel("X轴");
            plt.YLabel("Y轴");
            formsPlot1.Refresh();
        }
    }
}

本期只是简单的建立了一个scottplot 小demo可以运行,但是这个demo还很简单,鼠标可以随意的缩放整个scottplot,下一期我将带大家继续完善这个项目,可以设置只能在X轴方向缩放、Y轴方向缩放或随意的左右进行拖放。

你可能感兴趣的:(C#,winform,scottplot,c#,winform,数据可视化)