Go to Date

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
alexiat
Newbie
Newbie
Posts: 5
Joined: Tue Aug 26, 2008 12:00 am

Go to Date

Post by alexiat » Thu Mar 19, 2009 12:04 pm

I have a line graph with the x-axis as DateTime. I would like to be able to go to today's date in the graph when the window is first displayed. Is there an easy way to do this?

Thanks.

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

Post by Yeray » Fri Mar 20, 2009 8:56 am

Hi alexiat,

Yes, you should set your bottom axis min and max manually. Here is a simple example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var day: TDateTime;
i: Integer;
begin
  Chart1.View3D := false;

  Chart1.AddSeries(TLineSeries.Create(nil));

  Chart1[0].XValues.DateTime := true;
  (Chart1[0] as TLineSeries).Pointer.Visible := true;

  day := Today - 100;

  for i:=0 to 500 do
    Chart1[0].AddXY((day + i), i*i);

  Chart1.Axes.Bottom.SetMinMax(Today - 3, Today + 3);
end;
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

alexiat
Newbie
Newbie
Posts: 5
Joined: Tue Aug 26, 2008 12:00 am

Post by alexiat » Fri Mar 20, 2009 4:08 pm

Thank you!

Post Reply