/** * Overridden to prevent drawing on other bars */ public function DataLabelPosition($dataset, $index, &$item, $x, $y, $w, $h, $label_w, $label_h) { if (!is_numeric($dataset)) { // doing this supports stacked grouped bar graph totals too list($d) = explode('-', $dataset); if ($d === 'totalpos') { if (isset($this->last_position_pos[$index])) { list($lpos, $l_h) = $this->last_position_pos[$index]; list($hpos, $vpos) = Graph::TranslatePosition($lpos); if ($vpos == 'ot') { return "above 0 -{$l_h}"; } } return 'above'; } if ($d === 'totalneg') { if (isset($this->last_position_neg[$index])) { list($lpos, $l_h) = $this->last_position_neg[$index]; list($hpos, $vpos) = Graph::TranslatePosition($lpos); if ($vpos == 'ob') { return "below 0 {$l_h}"; } } return 'below'; } } $pos = parent::DataLabelPosition($dataset, $index, $item, $x, $y, $w, $h, $label_w, $label_h); if ($label_h > $h && Graph::IsPositionInside($pos)) { $pos = str_replace(array('top', 'bottom', 'above', 'below'), 'middle', $pos); } if ($item->value > 0) { $this->last_position_pos[$index] = array($pos, $label_h); } else { $this->last_position_neg[$index] = array($pos, $label_h); } return $pos; }