我不确定为什么参考文献中有错误。 OxyPlot.Wpf.LineSeries
到OxyPlot.Series.Series
System.Collections.ObjectModel.Collection.Add(OxyPlot.Axes.Axis)
的最佳重载方法匹配包含一些无效参数。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OxyPlot;
using OxyPlot.Wpf;
using OxyPlot.Axes;
namespace points
{
public class PsdTest
{
public static PlotModel Filteringinvalidpoints()
{
var plotModel1 = new PlotModel();
plotModel1.Title = "Filtering invalid points";
var linearAxis1 = new LinearAxis();
linearAxis1.Position = AxisPosition.Bottom;
linearAxis1.Title = "X-axis";
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
linearAxis2.Title = "Y-axis";
plotModel1.Axes.Add(linearAxis2);
var lineSeries1 = new LineSeries();
lineSeries1.Title = "NaN";
lineSeries1.Points.Add(new DataPoint(double.NaN, double.NaN));
lineSeries1.Points.Add(new DataPoint(1, 0));
lineSeries1.Points.Add(new DataPoint(2, 10));
lineSeries1.Points.Add(new DataPoint(double.NaN, 20));
lineSeries1.Points.Add(new DataPoint(3, 10));
lineSeries1.Points.Add(new DataPoint(4, 0));
lineSeries1.Points.Add(new DataPoint(4.5, double.NaN));
lineSeries1.Points.Add(new DataPoint(5, 0));
lineSeries1.Points.Add(new DataPoint(6, 10));
lineSeries1.Points.Add(new DataPoint(double.NaN, double.NaN));
lineSeries1.Points.Add(new DataPoint(7, 0));
lineSeries1.Points.Add(new DataPoint(double.NaN, double.NaN));
plotModel1.Series.Add(lineSeries1);
var lineSeries2 = new LineSeries();
lineSeries2.Title = "PositiveInfinity";
lineSeries2.Points.Add(new DataPoint(double.PositiveInfinity, double.PositiveInfinity));
lineSeries2.Points.Add(new DataPoint(1, 1));
lineSeries2.Points.Add(new DataPoint(2, 11));
lineSeries2.Points.Add(new DataPoint(double.PositiveInfinity, 20));
lineSeries2.Points.Add(new DataPoint(3, 11));
lineSeries2.Points.Add(new DataPoint(4, 1));
lineSeries2.Points.Add(new DataPoint(4.5, double.PositiveInfinity));
lineSeries2.Points.Add(new DataPoint(5, 1));
lineSeries2.Points.Add(new DataPoint(6, 11));
lineSeries2.Points.Add(new DataPoint(double.PositiveInfinity, double.PositiveInfinity));
lineSeries2.Points.Add(new DataPoint(7, 1));
lineSeries2.Points.Add(new DataPoint(double.PositiveInfinity, double.PositiveInfinity));
plotModel1.Series.Add(lineSeries2);
var lineSeries3 = new LineSeries();
lineSeries3.Title = "NegativeInfinity";
lineSeries3.Points.Add(new DataPoint(double.NegativeInfinity, double.NegativeInfinity));
lineSeries3.Points.Add(new DataPoint(1, 2));
lineSeries3.Points.Add(new DataPoint(2, 12));
lineSeries3.Points.Add(new DataPoint(double.NegativeInfinity, 20));
lineSeries3.Points.Add(new DataPoint(3, 12));
lineSeries3.Points.Add(new DataPoint(4, 2));
lineSeries3.Points.Add(new DataPoint(4.5, double.NegativeInfinity));
lineSeries3.Points.Add(new DataPoint(5, 2));
lineSeries3.Points.Add(new DataPoint(6, 12));
lineSeries3.Points.Add(new DataPoint(double.NegativeInfinity, double.NegativeInfinity));
lineSeries3.Points.Add(new DataPoint(7, 2));
lineSeries3.Points.Add(new DataPoint(double.NegativeInfinity, double.NegativeInfinity));
plotModel1.Series.Add(lineSeries3);
return plotModel1;
}
}
}
答案 0 :(得分:0)
听起来你遇到了一些不同命名空间的问题。我不能说我完全明白你在尝试什么,所以这可能不会给你想要的结果,但我能够使用以下命名空间(通过nuget安装了OxyPlot.Wpf)来编译代码:
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
如果事实证明你是在追踪OxyPlot.Wpf
名称空间中的某些特定行为后,这可能会对你没有帮助。