Page 1 of 1

DateTimeFormat

Posted: Tue Apr 06, 2004 11:36 am
by 9080487
I'm having a problem with 6.04 in setting a date/time format for my x-axis. It seems that, whether I change the format in code

Chart1.Axis.Bottom.Labels.DateTimeFormat = "dd/mm/yy"

or via the TeeChart editor, the format remains as

dd/mm/yyyy hh:mm:ss

which I presume is my PC UK regional setting.

I'd like to 'fix' the format so it is the same regardless of the PC regional settings.

Am I missing something?

Regards

John

Posted: Tue Apr 06, 2004 11:43 am
by 9080487
Just to add to this, the format shown in the editor matches that set in the code, but the actual values on the axis are not in that format.

Posted: Tue Apr 06, 2004 2:58 pm
by Pep
Hi John,

I've tried here and works fine, could you please check if the following code works fine for you ?

Code: Select all

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scFastLine
    .Series(0).XValues.DateTime = True
    .Series(0).AddXY DateValue("3/04/2002"), 4.346001, "", clTeeColor
    .Series(0).AddXY DateValue("13/04/2002"), 3.503998, "", clTeeColor
    .Series(0).AddXY DateValue("14/04/2002"), 4.637001, "", clTeeColor
    .Series(0).AddXY DateValue("16/04/2002"), 3.785995, "", clTeeColor
    .Series(0).AddXY DateValue("18/04/2002"), 5.417007, "", clTeeColor
    .Series(0).AddXY DateValue("23/04/2002"), 5.218002, "", clTeeColor
    .Series(0).AddXY DateValue("24/04/2002"), 2.684021, "", clTeeColor
    .Series(0).AddXY DateValue("25/04/2002"), 2.753998, "", clTeeColor
    .Series(0).AddXY DateValue("28/04/2002"), 3.515015, "", clTeeColor
    .Axis.Bottom.Labels.DateTimeFormat = "dd/mm/yy"
    .Axis.Bottom.Labels.Angle = 90
End With
End Sub

Posted: Tue Apr 06, 2004 4:06 pm
by 9080487
Will try as suggested tomorrow.
However, a bit more information - this is a web app. I am generating the Teechart to a file on the server populating from an ADO recordset as below - the database is SQL 2000, and the first field is a datetime I'm then reading from a URL on the client, using the TeeChart ActiveX control.

Chart1.Series(intSerindex).Addxy rs.Fields(0),rs.Fields(2),rs.Fields(0),1

I've tried setting the datetime format in code on the server, I've tried setting in code on the client, in the 'onload' event and then calling 'repaint, and I've tried changing via the Editor, and in all instances, the display stays as dd/mm/yyy hh:mm:ss - the PC regional setting on both the client and the server.
If I try to change the format in code, the new format is displayed as the current format in the editor.

Posted: Wed Apr 07, 2004 2:25 pm
by Chris
Hi John,
Chart1.Series(intSerindex).Addxy rs.Fields(0),rs.Fields(2),rs.Fields(0),1
I see you are adding in text labels to your series, in which case this:
.Labels.DateTimeFormat = "dd/mm/yy"

Has no effect. Are the strings in rs.Fields(0) date formatted as "dd/mm/yy"? Most probably not, reading your messages carefully.

Alternatively, you could try:

Code: Select all

Chart1.Series(intSerindex).Addxy rs.Fields(0),rs.Fields(2),"",1[code] 

in which case:
.Labels.DateTimeFormat = "dd/mm/yy"

will have an effect.

Posted: Wed Apr 07, 2004 2:41 pm
by 9080487
Spot on! Thanks Chris.