Daylight saving

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Daylight saving

Post by Glenn F. Henriksen » Tue Aug 08, 2006 2:15 pm

How does the TeeChart handle the switch from and to daylight saving if date is for the x-axis?
Is it not handled or will if be like 02:00....03:00....02:00, when leaving daylight saving?
If it is not handle does it exists some simple way to implement it?

Thanks,

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Aug 08, 2006 2:49 pm

Hello,

This will depend on the data you add in to teechart, such changes have to be handled manually. There's an example of how you can do this, although in a different context to the one you mention, in the features demo under:
Welcome !\Chart styles\Financial\Candle (OHLC)\Axis Labels no Weekends
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

matthbri
Newbie
Newbie
Posts: 43
Joined: Wed Mar 22, 2006 12:00 am

Post by matthbri » Tue Aug 08, 2006 5:44 pm

OK, I was anticipating this reply.

I think this is an oversight on Steemas part. Your DateTime axis should work with UTC values and display the labels as localtime. In fact it would be nice to have this as a selectable item.

How do I request this as a future feature?

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Aug 08, 2006 6:03 pm

Hello,

Well, there is another way to look at this. Given that your win app will know the difference between UTC and localtime on any given computer it will be able to make the appropriate addition/subtraction to the DateTime instance before adding the data to the chart. I can't imagine this will represent much overhead either in terms of application performance or in code complexity.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

matthbri
Newbie
Newbie
Posts: 43
Joined: Wed Mar 22, 2006 12:00 am

Post by matthbri » Wed Aug 09, 2006 9:49 pm

OK, so you dont want to do it. Looking at the Axis.cs, it would be quite a simple change for you, but lots of work for me.

Definitely an oversight on your part.

thanks anyway,

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu Aug 10, 2006 7:16 am

Hello,

I don't believe that I've said that I didn't want to do it.

Could you be so kind as to explain to me the kind of simple change you had in mind for Axis.cs?

Thank you very much.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

matthbri
Newbie
Newbie
Posts: 43
Joined: Wed Mar 22, 2006 12:00 am

Post by matthbri » Thu Aug 10, 2006 2:30 pm

Hi,

well basically what I was thinking was a new Property, LabelsAsLocalTime, that if false behaves just as now, and if true the labeling uses DateTime.ToLocalTime() instead of the DateTime itself. It would only be relevant if the DateTimes were all UTC, but thats OK.

Brian

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu Aug 10, 2006 3:54 pm

Hello,

OK, I've added a new property to the AxisLabels class called 'LabelsAsLocalTime' which will become available in the maintenance release due out in September.

In the meantime you can get exactly the same effect with code similar to the following:

Code: Select all

    private bool labelsAsLocalTime;

    private void InitializeChart()
    {
      int length = 10;
      DateTime now = DateTime.Now.ToUniversalTime();
      Random rnd = new Random();
      tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm";
      for (int i = 0; i < length; i++)
      {
        line1.Add(now, rnd.NextDouble());
        now = now.AddHours(1);
      }
    }

    private void button1_Click(object sender, EventArgs e)
    {
      labelsAsLocalTime = !labelsAsLocalTime;
      tChart1.Invalidate();
    }

    private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
    {
      if (labelsAsLocalTime && sender.Equals(tChart1.Axes.Bottom))
      {
        string s = e.LabelText;
        DateTime datetime = DateTime.Parse(s);
        e.LabelText = datetime.ToLocalTime().ToString(tChart1.Axes.Bottom.Labels.DateTimeFormat);
      }
    }
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

matthbri
Newbie
Newbie
Posts: 43
Joined: Wed Mar 22, 2006 12:00 am

Post by matthbri » Thu Aug 10, 2006 3:59 pm

thankyou! I did not expect that.

Brian

Post Reply