Page 1 of 1
db aware Gantt - Basic Questions
Posted: Thu Nov 16, 2006 1:24 pm
by 9241637
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
Posted: Fri Nov 17, 2006 10:43 am
by narcis
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;