Page 1 of 1

Daylight saving

Posted: Tue Aug 08, 2006 2:15 pm
by 8119814
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,

Posted: Tue Aug 08, 2006 2:49 pm
by Chris
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

Posted: Tue Aug 08, 2006 5:44 pm
by 9790735
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?

Posted: Tue Aug 08, 2006 6:03 pm
by Chris
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.

Posted: Wed Aug 09, 2006 9:49 pm
by 9790735
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,

Posted: Thu Aug 10, 2006 7:16 am
by Chris
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.

Posted: Thu Aug 10, 2006 2:30 pm
by 9790735
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

Posted: Thu Aug 10, 2006 3:54 pm
by Chris
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);
      }
    }

Posted: Thu Aug 10, 2006 3:59 pm
by 9790735
thankyou! I did not expect that.

Brian