Hi guys!
I'm kind of stuck here. I've been trying to get a colorband in one of my graphs. The problem is that the axis on which I base the colorband has a datetime format, but I get an error stating that I have to supply a double.
My question is:
How do I create a colorband on a datetime-formatted axis with C#?
I already tried casting and converting the value, which is also done in another topic I found concerning a colorband using VB, but it doesn't seem to work the same way in C#. If someone could show me a correct C# example I would be very grateful.
Thx in advance,
Willy
Colorband using axis with datetime format (C#)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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 |
Hi Narcís!
Thx for your response. I've tried it, but it didn't help me
In that topic the date seems to be in an Ole Automation Date format (OADate), but how do I convert a value (date of another type) to an OADate. The only options I have corresponding to the intelli-sense are (UTC)filetime, binary and OADate.
The dates I have at my disposal are of the type string and are formatted like: yyyy-MM-dd hh:mm
Changing this into a date format is no problem, would it not be that there are no conversion options for the above mentioned formats.
The setup is as following:
In which format should the StartValue/EndValue be supplied - OADate or Double? Because when I enter a legit double value it does implement the colorband, but I dont know how the double values correspond to the date values. For example: StartValue 0 and EndValue 75 just make the colorband span the whole graph and probably beyond that too.
Could you shed some light on this for me, am I missing something here?
Regards,
Willy (completely clueless atm)
Thx for your response. I've tried it, but it didn't help me
In that topic the date seems to be in an Ole Automation Date format (OADate), but how do I convert a value (date of another type) to an OADate. The only options I have corresponding to the intelli-sense are (UTC)filetime, binary and OADate.
The dates I have at my disposal are of the type string and are formatted like: yyyy-MM-dd hh:mm
Changing this into a date format is no problem, would it not be that there are no conversion options for the above mentioned formats.
The setup is as following:
Code: Select all
tChart1.Tools.get_Items(0).asColorband.Axis = tChart1.Axis.Bottom;
tChart1.Tools.get_Items(0).asColorband.StartValue =Convert.ToDateTime("2006-11-01 08:00").ToOADate;
tChart1.Tools.get_Items(0).asColorband.EndValue = Convert.ToDateTime("2006-11-02 16:00").ToOADate;
tChart1.Tools.get_Items(0).asColorband.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue));
tChart1.Tools.get_Items(0).asColorband.Transparency = 75;
tChart1.Tools.get_Items(0).asColorband.DrawBehind = true;
Could you shed some light on this for me, am I missing something here?
Regards,
Willy (completely clueless atm)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Willy,
You should try using DateTime.Parse method and then ToOADate method to convert a DateTime value to a double. It works fine for me here doing this:
You should try using DateTime.Parse method and then ToOADate method to convert a DateTime value to a double. It works fine for me here doing this:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
Random YVal = new Random();
axTChart1.Series(0).XValues.DateTime = true;
axTChart1.Series(0).AddXY(DateTime.Parse("29/10/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("30/10/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("31/10/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("1/11/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("2/11/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("3/11/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Series(0).AddXY(DateTime.Parse("4/11/2006").ToOADate(), YVal.Next(), "", axTChart1.Series(0).Color);
axTChart1.Tools.get_Items(0).asColorband.Axis = axTChart1.Axis.Bottom;
axTChart1.Tools.get_Items(0).asColorband.StartValue = DateTime.Parse("2006-11-01 08:00").ToOADate();
axTChart1.Tools.get_Items(0).asColorband.EndValue = DateTime.Parse("2006-11-02 16:00").ToOADate();
axTChart1.Tools.get_Items(0).asColorband.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue));
axTChart1.Tools.get_Items(0).asColorband.Transparency = 75;
axTChart1.Tools.get_Items(0).asColorband.DrawBehind = true;
}
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 |
Hi Narcís
Thats the frustrating part, I already tried that setup. It doesn't result into an error, but it also doesn't implement a colorband... at least that was my first thought. It actually does implement a colorband, but somewhere in the year 2143 AD (no idea which year exactly but beyond 2010 AD at least).
... OK, nevermind. This is so embarrasing The database value I used for my X-axis is the number of the hour, not the actual datetime. After I corrected this it worked exactly as it should - it was all due a simple mixup of values.
My apologies for the inconvenience , and thanks for the superb support!
Best regards,
Willy (less clueless)
Thats the frustrating part, I already tried that setup. It doesn't result into an error, but it also doesn't implement a colorband... at least that was my first thought. It actually does implement a colorband, but somewhere in the year 2143 AD (no idea which year exactly but beyond 2010 AD at least).
... OK, nevermind. This is so embarrasing The database value I used for my X-axis is the number of the hour, not the actual datetime. After I corrected this it worked exactly as it should - it was all due a simple mixup of values.
My apologies for the inconvenience , and thanks for the superb support!
Best regards,
Willy (less clueless)