For some reason the data does not display. I've looked at the example code provide under the Program Group, but obviously something is missing.
Here is what I am trying:
public Form1()
{
InitializeComponent();
tChart1.Series.Clear();
// Test data
double[] yData = new double[10];
double[] zData = new double[10];
DateTime[] xData = new DateTime[10];
for (int index = 0; index < 10; index++)
{
TimeSpan ts = new TimeSpan(index, 0, 0, 0);
xData[index] = DateTime.Now + ts;
yData[index] = index;
zData[index] = 20 * Math.Sin(index * Math.PI / 5);
}
Surface s = new Surface();
s.UseColorRange = false;
s.UsePalette = true;
s.PaletteStyle = PaletteStyles.Strong;
s.XValues.DateTime = true;
s.Add(xData, zData, yData);
tChart1.Series.Add(s);
}
Surface not visible but legend is
Re: Surface not visible but legend is
Hello skruegel,
I am afraid that using surface in your code, your application doesn't work fine for reasons that explain in this link. On the other hand, I recommend you use colorGrid Series, as do in next example code:
Could you tell us if previous code works as you want?
I hope will helps.
Thanks,
I am afraid that using surface in your code, your application doesn't work fine for reasons that explain in this link. On the other hand, I recommend you use colorGrid Series, as do in next example code:
Code: Select all
public Form1()
{
InitializeComponent();
tChart1.Series.Clear();
// Test data
double[] yData = new double[10];
double[] zData = new double[10];
DateTime[] xData = new DateTime[10];
for (int index = 0; index < 10; index )
{
TimeSpan ts = new TimeSpan(index, 0, 0, 0);
xData[index] = DateTime.Now ts;
yData[index] = index;
zData[index] = 20 * Math.Sin(index * Math.PI / 5);
}
ColorGrid s = new ColorGrid();
s.UseColorRange = false;
s.UsePalette = true;
s.PaletteStyle = PaletteStyles.Strong;
s.XValues.DateTime = true;
s.Add(xData, zData, yData);
tChart1.Series.Add(s);
}
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Surface not visible but legend is
No, I'm afraid that sample does not produce the results I need. The following example works as I expect it would. The only difference between this example and what I require is that I need one axis to be a DateTime.
This produces something close to what I need:
public Form1()
{
InitializeComponent();
tChart1.Series.Clear();
// Test data
Surface s = new Surface();
double[] yData = new double[10];
double[] zData = new double[10];
double[] xData = new double[10];
for (int xIndex = 0; xIndex < 10; xIndex++)
{
//TimeSpan ts = new TimeSpan(dateIndex, 0, 0, 0);
//DateTime dt = DateTime.Now + ts;
//xData[dateIndex] = dateIndex;
for (int zIndex = 0; zIndex < 10; zIndex++)
{
//zData[zIndex] = zIndex;
double y = xIndex + zIndex;
s.Add(xIndex, 20 * y, zIndex);
}
}
s.IrregularGrid = true;
s.UseColorRange = false;
s.UsePalette = true;
s.PaletteStyle = PaletteStyles.Strong;
//s.XValues.DateTime = true;
tChart1.Series.Add(s);
}
So, I have a set of DateTimes, each of which contains two arrays of the same size. One of those arrays is the independent variable, and the other is the dependent variable. In my example, x would be the DateTime, z would be the independent variable, and y would be the dependent variable.
This produces something close to what I need:
public Form1()
{
InitializeComponent();
tChart1.Series.Clear();
// Test data
Surface s = new Surface();
double[] yData = new double[10];
double[] zData = new double[10];
double[] xData = new double[10];
for (int xIndex = 0; xIndex < 10; xIndex++)
{
//TimeSpan ts = new TimeSpan(dateIndex, 0, 0, 0);
//DateTime dt = DateTime.Now + ts;
//xData[dateIndex] = dateIndex;
for (int zIndex = 0; zIndex < 10; zIndex++)
{
//zData[zIndex] = zIndex;
double y = xIndex + zIndex;
s.Add(xIndex, 20 * y, zIndex);
}
}
s.IrregularGrid = true;
s.UseColorRange = false;
s.UsePalette = true;
s.PaletteStyle = PaletteStyles.Strong;
//s.XValues.DateTime = true;
tChart1.Series.Add(s);
}
So, I have a set of DateTimes, each of which contains two arrays of the same size. One of those arrays is the independent variable, and the other is the dependent variable. In my example, x would be the DateTime, z would be the independent variable, and y would be the dependent variable.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Surface not visible but legend is
Hi skruegel,
The problem is not with DateTime data it's that your data doesn't have a grid structure as described in the thread Sandra pointed you. Please notice that to plot a Surface series cell you'll need 4 points to define each cell's boundaries. Having said that, I think the easiest way to achieve what you requested is using code snippet below where a regular grid is added to the series but those points not being in the "diagonal" are set to null.
The problem is not with DateTime data it's that your data doesn't have a grid structure as described in the thread Sandra pointed you. Please notice that to plot a Surface series cell you'll need 4 points to define each cell's boundaries. Having said that, I think the easiest way to achieve what you requested is using code snippet below where a regular grid is added to the series but those points not being in the "diagonal" are set to null.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Surface s = new Steema.TeeChart.Styles.Surface(tChart1.Chart);
s.XValues.DateTime = true;
for (int index = 0; index < 10; index++)
{
TimeSpan ts = new TimeSpan(index, 0, 0, 0);
for (int i = 0; i < 10; i++)
{
DateTime x = DateTime.Now + ts;
double y = i;
double z = 20 * Math.Sin(index * Math.PI / 5);
int tmp = s.Add(x.ToOADate(), z, y);
if (i != index) s.SetNull(tmp);
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |