IGanttSeries.AddGantt
IGanttSeries

function AddGantt(AStart, AEnd, AY: Double; Const SomeLabel: WideString): Integer;

Type Library
TeeChartx

Description
The AddGantt function adds a new Gantt bar to the Series. Each Gantt bar has the following parameters: AStart and AEnd The starting and ending Gantt bar horizontal coordinates. These can be normal floating values or DateTime values.

AY is the vertical Gantt bar coordinate. You can add as many Gantt bars you want, with or without same vertical coordinate. The vertical coordinate is usually a value starting from zero, but you can choose any other arbitrary value.

AXLabel is the associated Gantt bar text. It will be optionally shown as a Label at vertical axis and at GanttSeries.Marks.

You can assign connecting lines between Gantt bars by using the GanttSeries.NextTask property. You can assign a specific color to each Gantt bar by using the Series.PointColor property or by calling the TGanttBar.AddGanttColor method. This function returns the corresponding internal point index. You can then refer to this Gantt bar by using this index. New added points are optionally sorted in ascending or descending order either by their horizontal or vertical coordinates. You can turn sorting off by setting the XValues and YValues Order property to loNone.

Example [Visual Basic]:

This code adds several Gantt bars and connects them:

TChart1.AddSeries scGantt

With TChart1.Series(0).asGantt

.AddGantt DateValue("1/1/1997"), DateValue("31/1/1997"), 2, "Hello"

.AddGantt DateValue("15/1/1997"), DateValue("15/2/1997"), 1, "Nice"

.AddGantt DateValue("1/2/1997"), DateValue("28/2/1997"), 0, "World"

.AddGantt DateValue("1/3/1997"), DateValue("31/3/1997"), 2, ""

.AddGantt DateValue("1/4/1997"), DateValue("30/4/1997"), 0, ""

.AddGantt DateValue("15/3/1997"), DateValue("15/4/1997"), 1, ""

.NextTask.Value(0) = 3

.NextTask.Value(1) = 5

'change connecting lines

.ConnectingPen.Width = 3

.ConnectingPen.Color = vbBlue

' increase bar heights

.Pointer.VerticalSize = 16

End With

' remove legend

TChart1.Legend.Visible = False

'arrange bottom axis to show exact datetime labels

TChart1.Axis.Bottom.ExactDateTime = True

TChart1.Axis.Bottom.Increment = TChart1.GetDateTimeStep(dtOneMonth)