X Axis/Bottom Axis date format not what I want

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Iceman
Newbie
Newbie
Posts: 6
Joined: Thu Sep 04, 2003 4:00 am

X Axis/Bottom Axis date format not what I want

Post by Iceman » Wed Nov 10, 2010 9:05 pm

D 2009 Professional

How do I or where do I set the date format for the X Axis to be 'dd-mmm'

All else works great, thanks, Sean

Series1.XLabelsSource := 'Date';
dbChart1.Axes.Bottom.DateTimeFormat:='dd-mmm';
Series1.YValues.ValueSource := CBParameter1.Text;
Series2.YValues.ValueSource := CBParameter2.Text;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: X Axis/Bottom Axis date format not what I want

Post by Narcís » Thu Nov 11, 2010 8:26 am

Hi Iceman,

Yes, DateTimeFormat is what you should use. You may be missing XValues.DateTime:=True, for example:

Code: Select all

  Series1.XValues.DateTime:=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
Image Image Image Image Image Image
Instructions - How to post in this forum

Iceman
Newbie
Newbie
Posts: 6
Joined: Thu Sep 04, 2003 4:00 am

Re: X Axis/Bottom Axis date format not what I want

Post by Iceman » Thu Nov 11, 2010 7:04 pm

Hi, thanks for the advice but no change. It appears to use the system time despite setting the label format in code as you suggested. Any other ideas? Thanks, Sean

-----------------------------
TRY
Series1.ParentChart:=DBChart1;
Series1.DataSource:=qryDateSelectData;
Series2.ParentChart:=DBChart1;
Series2.DataSource:=qryDateSelectData;
dbChart1.Axes.Bottom.Items.Clear;
dbChart1.BottomAxis.Title.Caption := 'Date';

Series1.VertAxis := aLeftAxis;
//Series2.VertAxis := aLeftAxis;
Series2.VertAxis := aRightAxis;

dbChart1.Axes.Bottom.DateTimeFormat:='mmm-dd';
Series1.XLabelsSource := 'Date';
Series2.XLabelsSource := 'Date';
Series1.XValues.DateTime:=True;
Series2.XValues.DateTime:=True;
Series1.YValues.ValueSource := CBParameter1.Text;
Series2.YValues.ValueSource := CBParameter2.Text;

// scaling
dbChart1.LeftAxis.AutomaticMaximum := True;
dbChart1.LeftAxis.AutomaticMinimum := True;
dbChart1.RightAxis.AutomaticMaximum := True;
dbChart1.RightAxis.AutomaticMinimum := True;
//dbChart1.LeftAxis.Minimum := 0;

// prepare graph labeling
Series1.Title := CBParameter1.Text;
Series2.Title := CBParameter2.Text;;
dbChart1.LeftAxis.Title.Caption := CBParameter1.Text;;
dbChart1.RightAxis.Title.Caption := CBParameter2.Text;;

dbChart1.Legend.Visible := True;
dbChart1.Legend.Symbol.Visible := True;

Series1.Active := True;
Series2.Active := True;

dbChart1.SubTitle.Text.Clear;
dbChart1.Title.Text.Clear;
dbChart1.Title.Visible := True;
dbChart1.Title.Text.Add(CBParameter1.Text + ' vs. ' + CBParameter2.Text);

EXCEPT

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: X Axis/Bottom Axis date format not what I want

Post by Narcís » Fri Nov 12, 2010 9:04 am

Hi Iceman,

Calling dbChart1.Axes.Bottom.Items.Clear you remove all bottom axis labels. This should only be used if you are going to add custom labels manually after so I'd remove that line. Also, I see that you are assigning X labels from you datasource. Most likely those are text labels which are displayed by default in the bottom axis. To display X values instead of text labels you should do this:

Code: Select all

  DBChart1.Axes.Bottom.LabelStyle:=talValue;
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Iceman
Newbie
Newbie
Posts: 6
Joined: Thu Sep 04, 2003 4:00 am

Re: X Axis/Bottom Axis date format not what I want

Post by Iceman » Fri Nov 12, 2010 6:44 pm

That worked perfectly, thanks for your time and great support, Sean

Post Reply