新建窗体,并添加控件:PlotView,在load方法中添加如下代码
namespace OxyPlotWinform
{
public partial class FrmStairStepSeries : Form
{
public FrmStairStepSeries()
{
InitializeComponent();
}
private void FrmStairStepSeries_Load(object sender, EventArgs e)
{
var model = new PlotModel()
{
Title = "StairStep"
};
for (int j = 0; j < 1; j++)
{
StairStepSeries sss = new StairStepSeries {Title = "Serie" + j};
sss.Points.AddRange(new List<DataPoint>
{
new DataPoint(0, 32),
new DataPoint(1, 23), new DataPoint(2, 54), new DataPoint(3, 32), new DataPoint(4, 65),
new DataPoint(5, 29), new DataPoint(6, 25), new DataPoint(7, 12), new DataPoint(8, 24),
new DataPoint(9, 32), new DataPoint(10, 25)
});
model.Series.Add(sss);
}
plotView1.Model = model;
}
}
}
运行效果图:


本文介绍如何在Windows Forms应用程序中使用OxyPlot库创建并显示阶梯图。通过实例代码,展示了如何新建窗体,添加PlotView控件,设置PlotModel属性,以及在加载事件中添加数据点来生成阶梯序列。
1356

被折叠的 条评论
为什么被折叠?



