Page 1 of 1

X Axis/Bottom Axis date format not what I want

Posted: Wed Nov 10, 2010 9:05 pm
by 8439078
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;

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

Posted: Thu Nov 11, 2010 8:26 am
by narcis
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;

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

Posted: Thu Nov 11, 2010 7:04 pm
by 8439078
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

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

Posted: Fri Nov 12, 2010 9:04 am
by narcis
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!

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

Posted: Fri Nov 12, 2010 6:44 pm
by 8439078
That worked perfectly, thanks for your time and great support, Sean