db aware Gantt - Basic Questions

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
CAC
Newbie
Newbie
Posts: 44
Joined: Tue Jun 20, 2006 12:00 am
Location: Plain City, Ohio
Contact:

db aware Gantt - Basic Questions

Post by CAC » Thu Nov 16, 2006 1:24 pm

I want to improve on the data aware gantt's very basic functionality. I want to be able to change the color of the bar based on it status, which is provided in the data record along with its name, begin date and end date.

Also I want to find out if it is possible to make a "Project Bar" that automatically adjusts start and end dates based on the start and end dates of subordinate "Task Bars".

Thanks

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

Post by Narcís » Fri Nov 17, 2006 10:43 am

Hi CAC,
I want to improve on the data aware gantt's very basic functionality. I want to be able to change the color of the bar

based on it status, which is provided in the data record along with its name, begin date and end date.
Yes, you can do that using ColorSource property, for example:

Code: Select all

with Series1 do
begin
  YValues.ValueSource := 'Value'; 
  XLabelsSource := 'Text';
  ColorSource:='Color';
  DataSource := Table1;
end;
You'll find more information on how to use series with databases at Tutorial 8 - Database access. You'll find the

tutorials at TeeChart's program group.
Also I want to find out if it is possible to make a "Project Bar" that automatically adjusts start and end dates based

on the start and end dates of subordinate "Task Bars".
You can achieve that doing something like this:

Code: Select all

procedure TForm8.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
  DrawTaskBars;  
end;

procedure TForm8.DrawTaskBars;
var
  Start: Boolean;
  count, i, j, tmpIndex: Integer;
  tmpStart, tmpEnd: Double;
  ProjectSeries: TGanttSeries;
begin
  ProjectSeries:=TGanttSeries.Create(self);
  ProjectSeries.Marks.Visible:=true;
  ProjectSeries.Marks.Frame.Visible:=false;
  ProjectSEries.Marks.Brush.Style:=bsClear;
  Chart1.AddSeries(ProjectSeries);  
  
  count := 1;
  
  for i := 0 to Series1.Count - 1 do
  begin
    Start := true;

    for j := 0 to Series1.Count - 1 do
    begin
      if Series1.NextTask[j] = i then
      begin
        Start := false;
        break;
      end;
    end;
    
    if Start then
    begin
      tmpStart := Series1.StartValues[i];
      tmpIndex := i;
      
      while Series1.NextTask[tmpIndex] <> -1 do
        tmpIndex := Trunc(Series1.NextTask[tmpIndex]);
        
      tmpEnd := Series1.EndValues[tmpIndex];
      ProjectSeries.AddGantt(tmpStart, tmpEnd, Series1.Count + ProjectSeries.Count, 'Project ' + IntToStr(count));
      inc(count);
    end;
    
  end;
end;
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