DateTime on x axis of colorgrid
DateTime on x axis of colorgrid
I have a requirement for a colorgrid with DataTime on the x axis. What's the best way for this to be done?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi skruegel,
You can do something like this:
Hope this helps!
You can do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Labels.Angle = 90;
Steema.TeeChart.Styles.ColorGrid colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
colorGrid1.XValues.DateTime = true;
Random y = new Random();
for (int x = 0; x < 10; x++)
{
for (int z = 0; z < 10; z++)
{
colorGrid1.Add(DateTime.Now.AddDays(x).ToOADate(), y.Next(), z);
}
}
}
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 |
Narcis-
Here's what I'm trying to do:
Seems like it should be possible.
Here's what I'm trying to do:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Labels.Angle = 90;
Steema.TeeChart.Styles.ColorGrid colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
colorGrid1.XValues.DateTime = true;
List<DateTime> DateTimeList = new List<DateTime>();
List<double> Y = new List<double>();
List<double> Z = new List<double>();
DateTime currentDate = DateTime.Today;
for (int day = 0; day < 60; day++)
{
DateTimeList.Add(currentDate);
Y.Add((double)day);
Z.Add((double)day);
currentDate.AddDays(1);
}
for (int displayPoint = 0; displayPoint < 60; displayPoint++)
{
colorGrid1.Add(DateTimeList[displayPoint],Y[displayPoint],Z[displayPoint]);
}
}
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi skruegel,
Yes, two little problems here:
1. This ColorGrid needs setting IrregularGrid=true as described here.
2. You need to add DateTime values to a ColorGrid converting them to double using ToOADate method as in the example I posted.
This said, using code below works fine for me.
Yes, two little problems here:
1. This ColorGrid needs setting IrregularGrid=true as described here.
2. You need to add DateTime values to a ColorGrid converting them to double using ToOADate method as in the example I posted.
This said, using code below works fine for me.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Labels.Angle = 90;
Steema.TeeChart.Styles.ColorGrid colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
colorGrid1.XValues.DateTime = true;
colorGrid1.IrregularGrid = true;
List<DateTime> DateTimeList = new List<DateTime>();
List<double> Y = new List<double>();
List<double> Z = new List<double>();
DateTime currentDate = DateTime.Today;
for (int day = 0; day < 60; day++)
{
DateTimeList.Add(currentDate);
Y.Add((double)day);
Z.Add((double)day);
currentDate.AddDays(1);
}
for (int displayPoint = 0; displayPoint < DateTimeList.Count; displayPoint++)
{
colorGrid1.Add(DateTimeList[displayPoint].ToOADate(), Y[displayPoint], Z[displayPoint]);
}
}
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 |