Gantt Chart - Adding a "Today" line

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tri-Direct
Newbie
Newbie
Posts: 11
Joined: Tue Aug 24, 2004 4:00 am

Gantt Chart - Adding a "Today" line

Post by Tri-Direct » Thu Sep 02, 2004 1:35 pm

I've got a basic gantt chart that spreads across 1 year, with every 2 weeks marked on the x axis.

Basically, I want to remind the users what the current day position is. I want to do this by simply drawing a vertical line (or heavy grid line), at the point of todays date, stretching up through the chart.

How can I do this ?

regards

Mat Dunning

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

Post by Pep » Thu Sep 02, 2004 1:56 pm

Hi MAt,

you can do this by using the canvas techniques or using a ColorLineTool :
i.e. :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var day : TDate;
    i : integer;
begin
  day := Today;
  for i := -2 to 2 do
    Series1.AddXY(day+i,Random(100),'',clteecolor);

  Series1.XValues.DateTime := true;
  ChartTool1.Value := day;
end;

Tri-Direct
Newbie
Newbie
Posts: 11
Joined: Tue Aug 24, 2004 4:00 am

Post by Tri-Direct » Mon Sep 06, 2004 10:46 am

thanks for the quick reply. I've use the code you provided (but I must be doing something wrong), as this draws another small block on the Gantt, where "today" is, but what I want is a single line going from top to bottom showing where today is.

If I had the Random statement in the code, it simply drew this block "off" the gantt chart so I couldn't see it.

I can see you are using a color line chart tool, but i'm not sure how this is used in this case? Are then any properties I should be setting on the color line tool ?

regards

Mat

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Sep 06, 2004 10:56 am

Hi, Matt.
Are then any properties I should be setting on the color line tool ?
ColorLineTool has to be connected to specific axis, in your case series horizontal axis (chart bottom axis ?). The following code should do the trick:

Code: Select all

  colorlineTool1.AllowDrag := False;
  colorlineTool1.DragRepaint := False;
  colorlineTool1.Axis := Series1.GetHorizAxis;
  colorlineTool1.Value := Date;

  colorLineTool1.Pen.Width := 2;
  colorLineTool1.Pen.Color := clRed;
Marjan Slatinek,
http://www.steema.com

Post Reply