DateTime Format on Bottom Axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bsoft
Newbie
Newbie
Posts: 4
Joined: Mon Mar 03, 2008 12:00 am

DateTime Format on Bottom Axis

Post by bsoft » Mon Feb 17, 2014 12:05 pm

Hi,
I cannot format a datetime field to mm/yyyy or anything else format it shows full date and time.
I tried to format on the field properties at the dataset (cdsViewData), also in chart properties displaydateformat on bottom axis,
and i paste code in form event OnGetAxisLabel and in initialize form event...
But nothing works!
Please help,
Thanks a lot

Versions:
Delphi 7
Teechart Pro v8.07.70413

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: DateTime Format on Bottom Axis

Post by Yeray » Mon Feb 17, 2014 12:39 pm

Hello,

I can show dates in mm/yyyy DateTimeFormat without problems in the following simple example with Delphi 7 and TeeChart v8.08:

Code: Select all

uses Chart, Series, DateUtils, TeeProcs;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
var tmpDate: TDateTime;
    i: Integer;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;

  Chart1.View3D:=false;
  with Chart1.AddSeries(TLineSeries) as TLineSeries do
  begin
    XValues.DateTime:=true;

    tmpDate:=Today;
    for i:=0 to 5 do
    begin
      AddXY(tmpDate, random*100);
      tmpDate:=IncMonth(tmpDate);
    end;
  end;

  Chart1.Axes.Bottom.Increment:=DateTimeStep[dtOneMonth];
  Chart1.Axes.Bottom.DateTimeFormat:='mm/yyyy';
end;
Maybe there's some problem in your code. Please, try to arrange a simple example project we can run as-is to reproduce the problem here and we'll be glad to take a look at it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

bsoft
Newbie
Newbie
Posts: 4
Joined: Mon Mar 03, 2008 12:00 am

Re: DateTime Format on Bottom Axis

Post by bsoft » Mon Feb 17, 2014 1:49 pm

Bottom Axis Labels are automatic from database values that is datetime field.

So, i have
Datetime,Measure
01/01/2010 11:53:00, measurevalue1
02/01/2010 11:00:00, measurevalue2 etc..

And i want to show on diagram only 'mm/yyyy' but if i make another column in database with this string like
String, Measure
01/2010, measurevalue1
01/2010, measurevalue2 etc..

then i have no average function for my measure and measure it is not sum!
Is there any solution or i have to write code for each xy value ?

Thnx

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

Re: DateTime Format on Bottom Axis

Post by Narcís » Wed Feb 19, 2014 2:25 pm

Hi bsoft,

Have you set series X values to contain DateTime data? 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

Post Reply