Contents Previous Next

### 9.9.1 Adding caption to bars

Caption for bars are placed at the far right side of the bars. They can for example be used to indicate the resources assigned to a task, the duration of the task or the progress of the activity.

Caption text for a bar is specified either when creating a bar or later by accessing the 'caption' property of bars. So the two lines

`$activity = new GanttBar (0,"Activity 1", "2001-11-21", "2001-12-20", "[BS,ER]")`

and

`$activity-> caption->Set("[BS,ER]" );`

are both ways of specifying the caption "[BS,ER]" for the activity. Since activity is a standard JpGraph text object you can easily modify font, color and size with calls to SetFont() and SetColor(), (e.g.

`$activity->caption ->SetFont(FF_ARIAL, FF_BOLD,9);`

The figure below illustrates the use of caption

Figure 161: Illustration of the use of captions [src]

Contents Previous Next