protected function BarLabel($value, &$bar, $offset_y = null)
{
$font_size = $this->bar_label_font_size;
$space = $this->bar_label_space;
$x = $bar['x'] + $bar['width'] / 2;
$colour = $this->bar_label_colour;
$acolour = $this->bar_label_colour_above;
if (!is_null($offset_y)) {
$y = $bar['y'] + $offset_y;
} else {
// find positions
$pos = $this->bar_label_position;
if (empty($pos)) {
$pos = 'top';
}
$top = $bar['y'] + $font_size + $space;
$bottom = $bar['y'] + $bar['height'] - $space;
if ($top > $bottom) {
$pos = 'above';
}
$swap = $bar['y'] >= $this->height - $this->pad_bottom - $this->y0;
switch ($pos) {
case 'above':
$y = $swap ? $bar['y'] + $bar['height'] + $font_size + $space : $bar['y'] - $space;
if (!empty($acolour)) {
$colour = $acolour;
}
break;
case 'bottom':
$y = $swap ? $top : $bottom;
break;
case 'centre':
$y = $bar['y'] + ($bar['height'] + $font_size) / 2;
break;
case 'top':
default:
$y = $swap ? $bottom : $top;
break;
}
}
$text = array('x' => $x, 'y' => $y, 'text-anchor' => 'middle', 'font-family' => $this->bar_label_font, 'font-size' => $font_size, 'fill' => $colour);
if ($this->bar_label_font_weight != 'normal') {
$text['font-weight'] = $this->bar_label_font_weight;
}
return $this->Element('text', $text, NULL, $value);
}