Contents Previous Next

### 9.7.6 Adjusting the minimum distance between bars

Let's see what happens if we set the height of each bar to be 100% of the reserved height by adding another activity/bar below the first one and set the height of each bar to 100% by adding the lines (We omit the added lines to add another bar since they are just a copy of the first bar)

`$activity-> SetHeight(1.0);
$activity2 ->SetHeight(1.0);`

to the previous example. (Note that a value in the range [0..1] is interpretated as the fraction of the reserved height while a value > 1 is interpretated as the absolute size in pixels.)

Figure 157: Setting the height for each bar to 100% [src]

Aha.. What we are trying to do doesn't really make sense. Since we have specified that the bar will always occupy 100% of the available reserved with there will be no distance between the bars. So what if we specify the bar as 10 pixel absolute by changing the lines to

`$activity->SetHeight (10);
$activity2 ->SetHeight(10);`

we instead get

Figure 158: Setting both bars height to 10 pixels [src]

So what can we actually do? Well if you remember the reserved height for each bar is the maximum height of all bars including titles. This guarantees that no two bars will ever overlap. To guarantee that titles don't end up too close together there is a Vertical Label Margin which basically specifies some extra "air" in between the titles. The amount of air is specified in percent of the title height. To set the margin you use

`GanttGraph:: SetLabelVMarginFactor( $aMargin)`

As an example let's set that margin in the previous example to 0 and see what happens.

Figure 159: Setting the vertical label margin to 0% [src]

As you would perhaps expect the two bars just barely touches now since there are no extra margin added. If the two bars hadn't had the extra right marker it would have looked very compressed.

By default the vertical margin is set to 40%.

Contents Previous Next