VS.Gantt()

You can create a Gantt chart by adding an instance VS.Gantt() to a VS.Shape() object.

myGantt=myShape.AddGantt();

A Gantt chart is a special kind of table with a specific set of columns and rows that contain tasks and their appropriate start dates, end dates, and duration. A shape that contains a Gantt chart cannot contain a VS.Table() or VS.Timeline.

Gantt charts contain tasks defined as VS.GanttTask() objects. You add tasks to a Gantt chart using:

myTask=myGantt.AddTask(name);

VS.GanttTask() objects have methods to set the properties of a task like its start date, duration, and dependencies.

You can also specificy column widths and labels using methods.

VS.Gantt() Methods

This method returns the object it adds:

  • AddColumnProperties() - Adds a VS.ColumnProperties() object that takes a numerical index value. Once added, you can use the standard table ColumnProperties() methods to define color, line thickness, and more.
  • AddGanttTask(Name) - Adds a task to the Gantt chart using the name specified.

The following methods return the Gantt object and can be chained together to modify the appearance and properties of the Gantt chart:

AddGanttTask()

Example

myTask=myGantt.AddGanttTask("Run Testing Plan");

Syntax

myEvent=myGantt.AddGanttTask(taskname);

The valuearray is formatted in name and value pairs like this {Name:"myColumnName",Value:"myValue"} where Name is one of the standard Gantt column names and Value is the value for the task.

Usage

This method adds a VS.GanttTask() object to the Gantt chart. The taskname is a string that appears in the task column of the chart. It is optional.

SetAllDaysAsWorkingDays()

Example

myGantt=myGantt.SetAllDaysAsWorkingDays(true);

Syntax

myGantt=myGantt.SetAllDaysAsWorkingDays(all);

Usage

The default for Gantt charts is 5 working days per week. This method overrides the default and sets all days as working days. When you set a duration for a task, it is measured in working days not calendar days. Setting AllDaysAsWorkingDays as true makes calendar days the same as working days (except for holidays).

SetColumnTitle()

Example

myGantt=myGantt.SetColumnTitle(VS.GanttChartColumnNames.Task, "Deliverable");

Syntax

myGantt=myGantt.SetColumnTitle(ColumnName,Title);

Usage

This method sets the name of a Gantt column.

By default every column of a Gantt chart has a name like Task, Start, End, and so on. This method allows you to set some of the names, but not all.

The ColumnName is a value from VS.GanttChartColumnNames. The title is a string.

You can set the names of only the columns shown in bold below.

VS.GanttChartColumnNames =
{
Row: "Row",
Task: "Task",
Start: "Start",
StartTime: "StartTime",
Length: "Length",
End: "End",
EndTime: "EndTime",
Parent: "Parent",
Master: "Master",
Person: "Person",
PercentComplete: "PercentComplete",
Department: "Department",
Cost: "Cost",
Custom: "Custom",
DateGrid: "DateGrid",
};

SetColumnWidth()

Example

myGantt=myGantt.SetColumnWidth(VS.GanttChartColumnNames.Task, 500);

Syntax

myGantt=myGantt.SetColumnTitle(ColumnName,Width);

Usage

This method overrides the default width of a Gantt column. The ColumnName should be a value from VS.GanttChartColumnNames like "Start" or "Department". The width is set in 1/100".

SetHolidays()

Example

myGantt=myGantt.SetHolidays(VS.GanttChartHolidays.USA);

Syntax

myGantt=myGantt.SetHolidays(country);

Usage

This method sets national holidays as non-working days based on the country. The following countries are supported: USA, UK, Australia, and Canada. The default is "None".

VS.GanttChartHolidays =
{
None: "None",
USA: "USA",
UK: "UK",
Australia: "Australia",
Canada: "Canada",
};

VS.GanttTask()

An instance of a VS.GanttTask() is created by adding one to a VS.Gantt() object:

myTask=myGantt.AddTask(name);

VS.GanttTask() Methods

All of the task methods below return the Task and they can be chained together:

SetTaskNumber()

Example

myTask=myTask.SetTaskNumber(12);

Syntax

myTask=myTask.SetTaskNumber(tasknumber);

Usage

This method sets the task number of a task. By default the number of a task is the order in which it was added. Task 1 is the first task added, Task 2 the second and so on. Task numbers are used to identify parent and masters of other tasks with SetParent() and SetMaster().

Note: Care should be taken when using this method not to cause collisions with automatically numbered tasks. For example, assigning the first task the number 2 will cause a collision with a second task that is automatically assigned 2. In practice the only reason to use this feature is to make it easier to identify specific tasks that will later become masters or parents. When doing this, assign numbers that are outside the range of sequential default numbering such as 200, 201 etc.

SetTaskName()

Example

myTask=myTask.SetTaskName("Run Tests");

Syntax

myTask=myTask.SetTaskName(taskname);

Usage

This method sets the name of the task as it will appear in the Gantt chart. This can also be set in the VS.Gantt.AddTask(taskname) method.

SetStart()

Example

myTask=myTask.SetStart("2019-10-13");

Syntax

myTask=myTask.SetStart(datestring);

Usage

This method sets the start date of a task. By default top level tasks begin on the current day. Child tasks begin on the same day as their parent. Dependent tasks always begin when their master task ends. The datestring has the format YYYY-MM-DD.

SetStartTime()

Example

myTask=myTask.SetStartTime("13:01:00");

Syntax

myTask=myTask.SetStartTime(timestring);

Usage

This method sets the starting time a of a task on its start date. By default tasks begin at 00:00 on the start date. The timestring has the format HH-MM-SS.

SetDuration()

Example

myTask=myTask.SetDuration(11.33);

Syntax

myTask=myTask.SetDuration(duration);

Usage

This method sets the duration of a task in days. The end date of a task is the start date plus the duration. Note that duration is a floating point number allowing you to define a duration of days plus hours. By default tasks have a duration of 5 days.

SetParent()

Example

myTask=myTask.SetParent(2);

Syntax

myTask=myTask.SetParent(tasknumber);

Usage

This method sets this task to be a child of the task with the number specified. Task numbers are assigned as 1, 2, 3 etc based on the order of addition to the Gantt chart, this can be overridden using SetTaskNumber().

SetMaster()

Example

myTask=myTask.SetMaster(2);

Syntax

myTask=myTask.SetMaster(tasknumber);

Usage

This method sets this task to be dependent on the task with the number specified. This task starts when the specified task ends. Task numbers are assigned based on the order of addition to the Gantt chart, this can be overridden using SetTaskNumber().

SetAssignedTo()

Example

myTask=myTask.SetAssignedTo("Robert Smith");

Syntax

myTask=myTask.SetAssignedTo(person);

Usage

This method sets the name of the person assigned to the task and shows it in the AssignedTo Column. This column will only appear if one of the tasks sets a value for it or its width or title is set with myGantt.SetColumnWidth() or myGantt.SetColumnTitle().

SetCost()

Example

myTask=myTask.SetCost(1000);

Syntax

myTask=myTask.SetCost(value);

Usage

This method sets the value that will show for this row in the Cost Column. This column will only appear if one of the tasks sets a value for it or its width or title is set with myGantt.SetColumnWidth() or myGantt.SetColumnTitle().

SetDepartment()

Example

myTask=myTask.SetDepartment("Sales");

Syntax

myTask=myTask.SetDepartment(value);

Usage

This method sets the value that will show for this row in the Department Column. This column will only appear if one of the tasks sets a value for it or its width or title is set with myGantt.SetColumnWidth() or myGantt.SetColumnTitle().

SetCustom()

Example

myTask=myTask.SetCustom("High Priority");

Syntax

myTask=myTask.SetCustom(value);

Usage

This method sets the value that will show for this row in the CustomColumn. This column will only appear if one of the tasks sets a value for it or its width or title is set with myGantt.SetColumnWidth() or myGantt.SetColumnTitle().

Note that myGantt.SetColumnTitle() can be used to set an alternative title for the Custom column (or any column).

The following VS.Shape() methods also apply to Tasks:

SetFillColor()

Example

myTask=myTask.SetFillColor("#FF0000");

Syntax

myTask=myTask.SetFillColor(color);

Usage

This method sets the background color of the row in the Gantt chart that shows this task.

SetTextColor()

Example

myTask=myTask.SetTextColor("#FF0000");

Syntax

myTask=myTask.SetTextColor(color);

Usage

This method sets the text color of the row in the Gantt chart that shows this task.

SetTextBold()

Example

myTask=myTask.SetTextBold(true);

Syntax

myTask=myTask.SetTextBold(state);

Usage

This method sets the text of the row in the Gantt chart that shows this task to bold.

SetTextItalic()

Example

myTask=myTask.SetTextItalic(true);

Syntax

myTask=myTask.SetTextItalic(state);

Usage

This method sets the text of the task in a specific row to italic.

SetTextUnderline()

Example

myTask=myTask.SetTextUnderline(true);

Syntax

myTask=myTask.SetTextUnderline(state);

Usage

This method underlines the text of the row in the Gantt chart.

SetLineColor()

Example

myTask=myTask.SetLineColor("#FF0000");

Syntax

myTask=myTask.SetLineColor(color);

Usage

This method sets the color of the bar in the Gantt chart for the given task.

By continuing to use the website, you consent to the use of cookies.   Read More