我正在使用OxyPlot,一个用于C#的图形库。到目前为止让我困惑的是一些构造函数的type
。代码段如下:
public static PlotModel Notinterpolatedvalues() {
var plotModel1 = new PlotModel();
plotModel1.Subtitle = "Input text here";
var linearColorAxis1 = new LinearColorAxis();
linearColorAxis1.HighColor = OxyColors.Gray;
linearColorAxis1.LowColor = OxyColors.Black;
linearColorAxis1.Position = AxisPosition.Right;
plotModel1.Axes.Add(linearColorAxis1);
var linearAxis1 = new LinearAxis();
linearAxis1.Position = AxisPosition.Bottom;
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
plotModel1.Axes.Add(linearAxis2);
var heatMapSeries1 = new HeatMapSeries();
heatMapSeries1.X0 = 0.5;
heatMapSeries1.X1 = 1.5;
heatMapSeries1.Y0 = 0.5;
heatMapSeries1.Y1 = 2.5;
heatMapSeries1.Interpolate = false;
heatMapSeries1.Data = new Double[2, 3];
heatMapSeries1.Data[0, 0] = 0;
heatMapSeries1.Data[0, 1] = 0.2;
heatMapSeries1.Data[0, 2] = 0.4;
heatMapSeries1.Data[1, 0] = 0.1;
heatMapSeries1.Data[1, 1] = 0.3;
heatMapSeries1.Data[1, 2] = 0.2;
plotModel1.Series.Add(heatMapSeries1);
return plotModel1;
}
生成此图像:
(这是热图)
我的问题是 - var
是什么?例如,在创建新的多维数组时,执行以下操作:
double[,] doubleArray = new double[columns, rows];
理解情况下,此type
为double[,]
。为什么我需要知道这是因为我想将热图存储为实例变量,更具体地说,heatMapSeries1.Data
作为多维数组。但是,在VS中,我无法将var
声明为实例变量的类型。我得到的唯一选择是:
这里的任何OxyPlot专业人士都可以借给我一个帮助吗?谢谢。