The VS.GanttDocument() class is used to create a special type of VisualScript document that will be a Gantt chart. A VisualScript document is a description of a single VisualScript visual.

If you want to create a Gantt chart as your document, you will want to use this:

myDocument = new VS.GanttDocument();

Gantt charts are different from all other VisualScript visuals.

  • They require a specialized Document object that can only be used to generate a Gantt chart.
  • There can only be one Gantt chart per visual.
  • They cannot be mixed with other shapes, or appear in ShapeContainers, ShapeConnectors, Tables or other normal VisualScript layouts.

Building a Gantt chart with VisualScript is very simple: Create a GanttDocument() and call myGantt.AddTasks() for each task. AddTasks() takes an array of column names and values. Gantt charts have a pre-existing set of standard column names:

VS.GanttChartColumnNames =
Row: "Row",
Task: "Task",
Start: "Start",
Length: "Length",
End: "End",
Parent: "Parent",
Master: "Master",
Person: "Person",
PercentComplete: "PercentComplete",
Department: "Department",
Cost: "Cost",
Custom: "Custom",

The meanings of these columns, along with examples of their use, are explained in detail in the chapter about Gantt charts in the VisualScript Cookbook.

The Gantt chart you create will adjust the time scale to fit all of the events added automatically.

Here's an example of a Gantt chart created using VisualScript. The colors, fonts, and spacing are all fixed.

Gantt chart example

VS.GanttDocument() Methods

  • AddTask() - Takes an array of Name/Value pairs for the known columns in a Gantt chart defined by VS.GanttChartColumnNames()
  • SetColumnSettings() - Used to change the title and/or width of an existing column
  • SetOptions() - Used to set the working days and holidays
  • toJSON() - Converts the VisualScript GanttDocument object into a JSON string.



myDataRow=myGanttDocument.AddTask([{Name:VS.GanttChartColumnNames.Row,Value:1},{Name:VS.GanttChartColumnNames.Task,Value:"Write Spec"}]);



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.


This method is used to add a task to the Gantt chart. For details see the VisualScript Cookbook chapter on Gantt Charts.







This method can change the label of a standard column, or set its width, or both. The Title defines the new label for the column that will appear in the chart. If this value is null it is ignored. The Width is the new width of the column express in 1/100" increments. If it is null, it is ignored.







By default a Gantt chart assumes that only Monday-Friday are working days that count towards the length of a task. It also deducts US holidays from working days. This method allows an override on these assumptions.

AllWorkingDays=true sets all seven days of the week as working days.

Holidays can be any of the following values:

VS.GanttChartHolidays =
None: "None",
UK: "UK",
Australia: "Australia",
Canada: "Canada",







This method is called to transform the VisualScript GanttDocument object into a JSON file VisualScript will use to render as a visual. The Callback function implemented with the built-in JavaScript Editor expects to be called with a JSON string as an argument:

Sample code to build the VisualScript GanttDocument object:


This method can also be used by code that implements a REST endpoint called by a built-in REST endpoint report (or SmartDraw extension). The REST endpoint should also pass back a JSON string.

VisualScript will expect VSON markup to be returned by any REST endpoint so it can generate a visual.