YOUSEFUL / DELPHI / COMPONENTS

TAtlasGantt

Grid-based Gantt chart over a TAtlasTaskPlan: one row per task with caption, predecessor IDs, a timeline bar and a progress fill.

Visual control Palette: Atlas Unit Atlas.Gantt · Inherits TCustomDrawGrid · Product Atlas VCL

Description

TAtlasGantt is a TCustomDrawGrid with two columns. Row 0 is fixed: Task / predecessors on the left and, on the right, the date range from the earliest task start to the latest task end (dd mmm yyyy - dd mmm yyyy). Each further row is one task in the order of TAtlasTaskPlan.Tasks: the caption followed by the IDs of its predecessors in brackets (Build [1]), and a bar positioned proportionally within that range with the completed share filled in a second colour and the progress printed inside. The bar colours are fixed data colours and do not follow the UI theme; the surrounding grid uses Color, FixedColor and Font.

The control listens to its Plan and rebuilds its rows after every change; freeing the plan detaches it. Rows are selectable (goRowSelect); MoveSelected shifts the task of the selected row by a number of days through TAtlasTaskPlan.UpdateTask. The timeline column is resized to fill the control. Not implemented: dragging bars, editing captions in place, dependency arrows, a calendar scale with weekends, zooming or printing. The published VCL properties Align, Anchors, Font, Color, FixedColor, ParentFont and TabStop are available.

Members

MemberKindWhat it does
CreateconstructorCreates the grid 900 × 400 pixels with two columns (240 pixel task column), one fixed header row, 36 pixel rows, row selection and thumb tracking.
DestroydestructorDetaches from the plan (listener and free notification).
MoveSelectedmethodShifts the task in the selected row by Days (fractions allowed, negative moves earlier), keeping caption, duration and progress, through TAtlasTaskPlan.UpdateTask.
PlanpropertyThe model to display.

Constructors

Create constructor

constructor Create(AOwner: TComponent); override;

Creates the grid 900 × 400 pixels with two columns (240 pixel task column), one fixed header row, 36 pixel rows, row selection and thumb tracking. The first task row is selected initially, so MoveSelected acts on the first task until the user selects another row.

Destructors

Destroy destructor

destructor Destroy; override;

Detaches from the plan (listener and free notification).

Properties

Plan property

property Plan: TAtlasTaskPlan read FPlan write SetPlan;

The model to display. Assigning registers a listener and a free notification and rebuilds the rows; without a plan the grid shows the header and one empty row.

pascal
Gantt := TAtlasGantt.Create(Form);
Gantt.Parent := Form;
Gantt.Align := alBottom;
Gantt.Height := 200;
Gantt.Plan := Plan;

Methods

MoveSelected method

procedure MoveSelected(Days: Double);

Shifts the task in the selected row by Days (fractions allowed, negative moves earlier), keeping caption, duration and progress, through TAtlasTaskPlan.UpdateTask. Does nothing without a plan or when the plan has no tasks. Raises EAtlasGraphError when the new interval leaves the valid date range. Dependencies are not re-evaluated; call TAtlasTaskPlan.AutoSchedule to restore finish-to-start order.

pascal
Gantt.MoveSelected(1);    // one day later
Gantt.MoveSelected(-0.5); // half a day earlier

Examples

Gantt chart under a form's other controls

Shows an auto-scheduled plan; the button handler shifts the selected task a day later.

pascal
uses System.SysUtils, Vcl.Controls, Vcl.Forms, Atlas.Gantt;

function AddGantt(Form: TForm; Start: TDateTime): TAtlasGantt;
var
  Plan: TAtlasTaskPlan;
  Design, Build: Integer;
begin
  Plan := TAtlasTaskPlan.Create(Form);
  Design := Plan.AddTask('Design', Start, Start + 2, 100);
  Build := Plan.AddTask('Build', Start, Start + 5, 40);
  Plan.AddDependency(Design, Build);
  Plan.AutoSchedule(Start);              // Build now starts two days after Start
  Result := TAtlasGantt.Create(Form);
  Result.Parent := Form;
  Result.Align := alBottom;
  Result.Height := 200;
  Result.Plan := Plan;
  Result.MoveSelected(1);                // shifts the task in the selected row one day later
end;

TAtlasTaskPlan · TAtlasTask · TAtlasThemer

Also in Atlas VCL

TAtlasTable · TAtlasGrid · TAtlasValueEdit · TAtlasTree · TAtlasWorkbook · TAtlasSheetGrid · TAtlasPivot · TAtlasInspector · TAtlasRichEdit · TAtlasSpellChecker · TAtlasChart · TAtlasGauge · TAtlasThemer · TAtlasWizard · TAtlasWorkspace · TAtlasCommandBar · TAtlasActionTile · TAtlasTileBoard · TAtlasNavigation · TAtlasMap · TAtlasGraph · TAtlasDiagram · TAtlasPrintDocument · TAtlasSchedule · TAtlasScheduler · TAtlasTaskPlan · TAtlasPdfDocument · TAtlasPdfViewer