DateTimeFormat

TeeChart for ActiveX, COM and ASP
Post Reply
JohnHorb
Newbie
Newbie
Posts: 12
Joined: Wed Jan 14, 2004 5:00 am
Location: UK
Contact:

DateTimeFormat

Post by JohnHorb » Tue Apr 06, 2004 11:36 am

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

JohnHorb
Newbie
Newbie
Posts: 12
Joined: Wed Jan 14, 2004 5:00 am
Location: UK
Contact:

Post by JohnHorb » Tue Apr 06, 2004 11:43 am

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.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Apr 06, 2004 2:58 pm

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

JohnHorb
Newbie
Newbie
Posts: 12
Joined: Wed Jan 14, 2004 5:00 am
Location: UK
Contact:

Post by JohnHorb » Tue Apr 06, 2004 4:06 pm

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.

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 » Wed Apr 07, 2004 2:25 pm

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.
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/

JohnHorb
Newbie
Newbie
Posts: 12
Joined: Wed Jan 14, 2004 5:00 am
Location: UK
Contact:

Post by JohnHorb » Wed Apr 07, 2004 2:41 pm

Spot on! Thanks Chris.

Post Reply