case的demo如附件,原本用winform下自带的mschart实现
用C1CHART 或 C1CHART3D尝试的代码如下(我注意到,winform版的c1chart3d包含bar这种type,外形与column类似,但wpf版只有surface)
void chartLoad3D()
{
this.chart.Children.Clear();
int xlen = 100, ylen = 50;
double[,] zdata0 = new double[xlen, ylen];
for (int ix = 0; ix < xlen; ix++)
{
for (int iy = 0; iy < ylen; iy++)
{
zdata0[ix, iy] = ix - iy;
}
}
this.chart.Children.Add(new GridDataSeries() { ZData = zdata0 });
}
void chartLoadXY()
{
int xlen = 100, ylen = 50;
double[][] zdata = new double[ylen][];
int[] xdata = new int[xlen];
int[] ydata = new int[ylen];
for (int iy = 0; iy < ylen; iy++)
{
ydata[iy] = iy;
zdata[iy] = new double[xlen];
for (int ix = 0; ix < xlen; ix++)
{
zdata[iy][ix] = ix - iy;
if (iy == 0)
{
xdata[ix] = ix;
}
}
}
this.chart1.Data.Children.Clear();
for (int iy = 0; iy < ylen; iy++)
{
XYDataSeries ds = new XYDataSeries();
ds.ChartType = ChartType.Column3D;
ds.XValuesSource = xdata;
ds.ValuesSource = zdata[iy];
this.chart1.Data.Children.Add(ds);
}
}
void chartLoadXYZ()
{
int xlen = 100, ylen = 50;
double[][] zdata = new double[ylen][];
int[] xdata = new int[xlen];
int[] ydata = new int[ylen];
for (int iy = 0; iy < ylen; iy++)
{
ydata[iy] = iy;
zdata[iy] = new double[xlen];
for (int ix = 0; ix < xlen; ix++)
{
zdata[iy][ix] = ix - iy;
if (iy == 0)
{
xdata[ix] = ix;
}
}
}
this.chart1.Data.Children.Clear();
XYZDataSeries d3 = new XYZDataSeries();
d3.ChartType = ChartType.Column3D;
d3.Points = new System.Windows.Media.Media3D.Point3DCollection();
for (int iy = 0; iy < ylen; iy++)
{
for (int ix = 0; ix < xlen; ix++)
{
System.Windows.Media.Media3D.Point3D p3 = new System.Windows.Media.Media3D.Point3D();
p3.X = xdata[ix];
p3.Y = ydata[iy];
p3.Z = zdata[iy][ix];
d3.Points.Add(p3);
}
}
this.chart1.Data.Children.Add(d3);
}
|