Hello大家好我是开箱测评小汪
效果图
本次课程的要达到的目的:
1、 安装上scottplot控件
2、 创建第一个简单的scottplot demo程序
环境:
Visual Studio 2019 .net5.0
1、创建工程
2、使用Nuget 安装scottplot控件库
配置控件属性,使控件大小随窗口大小一起缩放
程序源码:
文件名: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轴方向缩放或随意的左右进行拖放。