procedure CreateProjectSchedule(GanttSeries: TGanttSeries; Chart: TChart);
begin
// Set 2D view for clarity
Chart.View3D := False;
// Disable automatic sorting by date
GanttSeries.XValues.Order := loNone;
// Add tasks with date-time values
// AddGantt parameters: (StartDate, EndDate, YPosition, Label)
with GanttSeries do
begin
AddGantt(EncodeDate(2003, 4, 1), EncodeDate(2003, 4, 10), 0, 'Task A');
AddGantt(EncodeDate(2003, 4, 5), EncodeDate(2003, 4, 15), 1, 'Task B');
AddGantt(EncodeDate(2003, 4, 2), EncodeDate(2003, 4, 8), 2, 'Task C');
AddGantt(EncodeDate(2003, 4, 9), EncodeDate(2003, 4, 21), 3, 'Task D');
// Multiple bars on the same row (Y position)
AddGantt(EncodeDate(2003, 4, 12), EncodeDate(2003, 4, 18), 2, 'Task C2');
// Make marks visible
Marks.Visible := True;
Marks.Shadow.Size := 0;
Marks.Gradient.Visible := True;
end;
// Configure horizontal axis for dates
Chart.BottomAxis.SetMinMax(EncodeDate(2003, 4, 1), EncodeDate(2003, 5, 1));
Chart.BottomAxis.Increment := DateTimeStep[dtOneDay];
Chart.BottomAxis.LabelsAngle := 90;
Chart.BottomAxis.DateTimeFormat := 'dd-mmm';
// Configure vertical axis for tasks
Chart.LeftAxis.SetMinMax(-2, 5);
Chart.LeftAxis.Grid.Centered := False;
end;