/** * Overridden to prevent drawing behind higher bars * $offset_y should be true for inner bars */ protected function BarLabel($value, &$bar, $offset_x = null) { list($text_size) = $this->TextSize(strlen($value), $this->bar_label_font_size, $this->bar_label_font_adjust); $space = $this->bar_label_space; if ($offset_x) { // bar too small, would be above if ($bar['width'] < $text_size + 2 * $space) { return parent::BarLabel($value, $bar, ($bar['width'] + $text_size) / 2); } // option set to above if ($this->bar_label_position == 'above') { $this->bar_label_position = 'top'; $label = parent::BarLabel($value, $bar); $this->bar_label_position = 'above'; return $label; } } return parent::BarLabel($value, $bar); }
/** * Overridden to prevent drawing behind higher bars * $offset_x should be true for inner bars */ protected function BarLabel(&$item, &$bar, $offset_x = null) { $content = $item->Data('label'); if (is_null($content)) { $content = $this->units_before_label . Graph::NumString($item->value) . $this->units_label; } list($text_size) = $this->TextSize($content, $this->bar_label_font_size, $this->bar_label_font_adjust, $this->encoding); $space = $this->bar_label_space; if ($offset_x) { // bar too small, would be above if ($bar['width'] < $text_size + 2 * $space) { return parent::BarLabel($item, $bar, ($bar['width'] + $text_size) / 2); } // option set to above if ($this->bar_label_position == 'above') { $this->bar_label_position = 'top'; $label = parent::BarLabel($item, $bar); $this->bar_label_position = 'above'; return $label; } } return parent::BarLabel($item, $bar); }