GanttChartAnnotationTableDataModel: Setting Annotations

Annotation data for a Gantt chart can be stored in a GanttChartAnnotationTableDataModel or in a GanttChartTableDataModel. Using the GanttChartAnnotationTableDataModel is recommended when you need maximum flexibility for setting multiple annotations on a single bar.

A GanttChartAnnotationTableDataModel provides the following methods for setting the annotations on a chart:

setTaskVariable(Variable)
Specifies a variable whose values identify the task bars to use for displaying the annotations. Each of the values on the specified variable must match one of the values of the GanttChartTableDataModel Task variable.
setSymbolVariable(Variable)
Specifies an Integer variable whose values identify the annotation symbol to display. Valid symbols are listed in the MarkerStyle class.
Example value: MarkerStyle.SYMBOL_ASTERISK.
setSymbolColorVariable(Variable)
Specifies a String variable whose values identify the colors to use for the annotation symbols.
Example value: "white".
setLabelVariable(Variable)
Specifies a String variable whose values identify the annotation label to display.
Example value: "tenuous date >>>".
setLabelColorVariable(Variable)
Specifies a String variable whose values identify the colors to use for the annotation labels.
Example value: "white".
setLocationVariable(Variable)
Specifies a String variable that identifies a relative location on the date axis. The location is based on a task's start or finish date. Accepts one of four enumeration values: ES, LS, EF, or LF. For details, see Positioning Annotations in the Chart.
setPositionVariable(Variable)
Specifies a String variable that identifies a specific date on the date axis. For details, see Positioning Annotations in the Chart.

The following table shows data for three annotations: two symbols and a text label. The table header shows the variable names used in the data, and the rows show the data values.

Task Symbol Label Position Color
Manufacturer Demos MarkerStyle.SYMBOL_DIAMOND_FILLED null 04NOV blue
Determine Users null tenuous date >>> 06NOV blue
Determine Users MarkerStyle.SYMBOL_SQUARE_FILLED null 03NOV blue

The following graph is generated when these variables are set in the GanttChartAnnotationTableDataModel, as shown by the code fragment.


// Create the model for the schedule data
   GanttChartTableDataModel dataModel=
     new GanttChartTableDataModel(scheduleData);

// Create the model for the annotation data
   GanttChartAnnotationTableDataModel annoModel=
     new GanttChartAnnotationTableDataModel(annoData);

// Set the annotation model on the schedule model
   dataModel.setAnnotationTableDataModel(annoModel);

// Assign the annotation values to the annotation data model
   annoModel.setTaskVariable(new Variable("Task"));

   annoModel.setSymbolVariable(new Variable("Symbol"));
   annoModel.setSymbolColorVariable(new Variable("Color"));

   annoModel.setLabelVariable(new Variable("Label"));
   annoModel.setLabelColorVariable(new Variable("Color"));

   annoModel.setPositionVariable(new Variable("Position", "DATE5.", "DATE5.", "Absolute Position"));

Example
Show Annotations for a GanttChart

GanttChartAnnotationTableDataModel: Positioning Annotations in the Chart

A GanttChartAnnotationTableDataModel provides two methods for positioning annotations along the date axis:

setLocationVariable(Variable)
Bases the location of the annotation on the corresponding task's start or finish date. If the start or finish date changes, the annotation location changes with it. Accepts one of four enumeration values:
ES Sets the annotation to the task's Early Start date
EF Sets the annotation to the task's Early Finish date
LS Sets the annotation to the task's Late Start date
LF Sets the annotation to the task's Late Finish date
setPositionVariable(Variable)
Sets an absolute position at a specified date. If the task's start or finish date changes, the annotation position is unaffected. This method is good for flagging holidays or other significant dates that are independent of the schedule dates. The method takes a single argument, which must be a valid Variable in the data, and the variable's values must be valid date values. For a particular task, the date can be outside of the task's start to finish range.

The following table shows data for two annotations. The table header shows the variable names used for the data, and the rows show the data values.

Task Symbol Location Position Color
Project Summary MarkerStyle.SYMBOL_DIAMOND_FILLED null 05NOV cyan
Needs Assessment MarkerStyle.SYMBOL_DIAMOND_FILLED ES null cyan

The following graph is generated when these variables are set in the GanttChartAnnotationTableDataModel, as shown by the code fragment.

 
// Create the model for the schedule data
   GanttChartTableDataModel dataModel=
     new GanttChartTableDataModel(scheduleData);

// Create the model for the annotation data
   GanttChartAnnotationTableDataModel annoModel=
     new GanttChartAnnotationTableDataModel(annoData);

// Set the annotation model on the schedule model
   dataModel.setAnnotationTableDataModel(annoModel);

// Assign the annotation values to the annotation data model
   annoModel.setTaskVariable(new Variable("Task"));

   annoModel.setSymbolVariable(new Variable("Symbol"));
   annoModel.setSymbolColorVariable(new Variable("Color"));

   annoModel.setLocationVariable(new Variable("Location"));
   annoModel.setPositionVariable(new Variable("Position", "DATE5.", "DATE5.", "Position"));