在Windows Forms应用程序中使用OxyPlot显示多个LineSeries,可以通过以下步骤实现:
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.WindowsForms;
private PlotView plotView;
public Form1()
{
InitializeComponent();
plotView = new PlotView();
plotView.Dock = DockStyle.Fill;
panel1.Controls.Add(plotView);
}
var series1 = new LineSeries
{
Title = "Series 1",
Color = OxyColors.Blue,
StrokeThickness = 2
};
series1.Points.Add(new DataPoint(0, 0));
series1.Points.Add(new DataPoint(1, 1));
series1.Points.Add(new DataPoint(2, 2));
var series2 = new LineSeries
{
Title = "Series 2",
Color = OxyColors.Red,
StrokeThickness = 2
};
series2.Points.Add(new DataPoint(0, 2));
series2.Points.Add(new DataPoint(1, 1));
series2.Points.Add(new DataPoint(2, 0));
var plotModel = new PlotModel();
plotModel.Series.Add(series1);
plotModel.Series.Add(series2);
plotView.Model = plotModel;
现在,运行应用程序,就可以在Windows Forms应用程序中使用OxyPlot显示多个LineSeries了。可以根据需要,添加更多的LineSeries,并设置它们的属性,以实现更丰富的图表展示效果。
领取专属 10元无门槛券
手把手带您无忧上云