protected function DrawTitle()
{
// graph_title is available for all graph types
if (strlen($this->graph_title) <= 0) {
return '';
}
$pos = $this->graph_title_position;
$text = array('font-size' => $this->graph_title_font_size, 'font-family' => $this->graph_title_font, 'font-weight' => $this->graph_title_font_weight, 'text-anchor' => 'middle', 'fill' => $this->graph_title_colour);
$lines = $this->CountLines($this->graph_title);
$title_space = $this->graph_title_font_size * $lines + $this->graph_title_space;
if ($pos != 'top' && $pos != 'bottom' && $pos != 'left' && $pos != 'right') {
$pos = 'top';
}
$pad_side = 'pad_' . $pos;
// ensure outside padding is at least the title space
if ($this->{$pad_side} < $this->graph_title_space) {
$this->{$pad_side} = $this->graph_title_space;
}
if ($pos == 'left') {
$text['x'] = $this->pad_left + $this->graph_title_font_size;
$text['y'] = $this->height / 2;
$text['transform'] = "rotate(270,{$text['x']},{$text['y']})";
} elseif ($pos == 'right') {
$text['x'] = $this->width - $this->pad_right - $this->graph_title_font_size;
$text['y'] = $this->height / 2;
$text['transform'] = "rotate(90,{$text['x']},{$text['y']})";
} elseif ($pos == 'bottom') {
$text['x'] = $this->width / 2;
$text['y'] = $this->height - $this->pad_bottom - $this->graph_title_font_size * ($lines - 1);
} else {
$text['x'] = $this->width / 2;
$text['y'] = $this->pad_top + $this->graph_title_font_size;
}
// increase padding by size of text
$this->{$pad_side} += $title_space;
// the Text function will break it into lines
return $this->Text($this->graph_title, $this->graph_title_font_size, $text);
}