/** * 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)) { if ($dataset === 'totalpos') { if (isset($this->last_position_pos[$index])) { list($lpos, $l_w) = $this->last_position_pos[$index]; list($hpos, $vpos) = Graph::TranslatePosition($lpos); if ($hpos == 'or') { return "middle outside right {$l_w} 0"; } } return 'outside right'; } if ($dataset === 'totalneg') { if (isset($this->last_position_neg[$index])) { list($lpos, $l_w) = $this->last_position_neg[$index]; list($hpos, $vpos) = Graph::TranslatePosition($lpos); if ($hpos == 'ol') { return "middle outside left -{$l_w} 0"; } } return 'outside left'; } } if ($dataset === 'totalpos') { return 'outside right'; } if ($dataset === 'totalneg') { return 'outside left'; } $pos = parent::DataLabelPosition($dataset, $index, $item, $x, $y, $w, $h, $label_w, $label_h); if ($label_w > $w && Graph::IsPositionInside($pos)) { $pos = str_replace(array('outside left', 'outside right'), 'centre', $pos); } if ($item->value > 0) { $this->last_position_pos[$index] = array($pos, $label_w); } else { $this->last_position_neg[$index] = array($pos, $label_w); } return $pos; }
/** * 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; }
/** * Returns the position for a data label */ public function DataLabelPosition($dataset, $index, &$item, $x, $y, $w, $h, $label_w, $label_h) { $pos = parent::DataLabelPosition($dataset, $index, $item, $x, $y, $w, $h, $label_w, $label_h); $bpos = $this->bar_label_position; if (!empty($bpos)) { $pos = $bpos; } if ($label_h > $h && Graph::IsPositionInside($pos)) { $pos = str_replace(array('top', 'middle', 'bottom'), 'outside top inside ', $pos); } // flip top/bottom for negative values if ($item->value < 0) { if (strpos($pos, 'top') !== FALSE) { $pos = str_replace('top', 'bottom', $pos); } elseif (strpos($pos, 'above') !== FALSE) { $pos = str_replace('above', 'below', $pos); } elseif (strpos($pos, 'below') !== FALSE) { $pos = str_replace('below', 'above', $pos); } elseif (strpos($pos, 'bottom') !== FALSE) { $pos = str_replace('bottom', 'top', $pos); } } return $pos; }
/** * Returns the position for a data label */ public function DataLabelPosition($dataset, $index, &$item, $x, $y, $w, $h, $label_w, $label_h) { $pos = parent::DataLabelPosition($dataset, $index, $item, $x, $y, $w, $h, $label_w, $label_h); $bpos = $this->bar_label_position; if (!empty($bpos)) { $pos = $bpos; } if ($label_w > $w && Graph::IsPositionInside($pos)) { $pos = str_replace(array('left', 'centre', 'right'), 'outside right inside', $pos); } // flip sides for negative values if ($item->value < 0) { if (strpos($pos, 'right') !== FALSE) { $pos = str_replace('right', 'left', $pos); } elseif (strpos($pos, 'left') !== FALSE) { $pos = str_replace('left', 'right', $pos); } } return $pos; }