/** * Returns the path for a guideline, and sets dimensions of the straight bit */ protected function GuidelinePath($axis, $value, $depth, &$x, &$y, &$w, &$h) { if ($depth == SVGG_GUIDELINE_ABOVE) { return parent::GuidelinePath($axis, $value, $depth, $x, $y, $w, $h); } $y_axis_pos = $this->height - $this->pad_bottom - $this->y_axes[$this->main_y_axis]->Zero(); $x_axis_pos = $this->pad_left + $this->x_axes[$this->main_x_axis]->Zero(); $z = $this->depth * $this->depth_unit; list($xd, $yd) = $this->Project(0, 0, $z); if ($axis == 'x') { $x1 = $x_axis_pos + $value * $this->x_axes[$this->main_x_axis]->Unit(); $y1 = $y_axis_pos; $x = $xd + $x1; $y = $this->pad_top; $w = 0; if ($h == 0) { $h = $this->g_height; } elseif ($h < 0) { $h = -$h; return "M{$x} {$y}v{$h}"; } else { $y = $this->height - $this->pad_bottom + $yd - $h; } } else { $x1 = $x_axis_pos; $y1 = $y_axis_pos - $value * $this->y_axes[$this->main_y_axis]->Unit(); $x = $this->pad_left + $xd; $y = $yd + $y1; $h = 0; if ($w == 0) { $w = $this->g_width; } elseif ($w < 0) { $w = -$w; $x = $this->pad_left + $xd + $this->g_width - $w; return "M{$x} {$y}h{$w}"; } } return "M{$x} {$y}l{$w} {$h}M{$x1} {$y1} l{$xd} {$yd}"; }
/** * Returns the style options for bar labels */ public function DataLabelStyle($dataset, $index, &$item) { $style = parent::DataLabelStyle($dataset, $index, $item); // bar label settings can override global settings $opts = array('font' => 'bar_label_font', 'font_size' => 'bar_label_font_size', 'font_weight' => 'bar_label_font_weight', 'colour' => 'bar_label_colour', 'altcolour' => 'bar_label_colour_above', 'space' => 'bar_label_space'); foreach ($opts as $key => $opt) { if (isset($this->settings[$opt])) { $style[$key] = $this->settings[$opt]; } } return $style; }
/** * Overload to measure keys */ protected function LabelAdjustment($longest_v = 1000, $longest_h = 100) { GridGraph::LabelAdjustment($longest_h, $longest_v); }
/** * 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); // labels don't fit inside markers $pos = str_replace(array('inner', 'inside'), '', $pos); if (strpos($pos, 'middle') !== FALSE && strpos($pos, 'right') === FALSE && strpos($pos, 'left') === FALSE) { $pos = str_replace('middle', 'top', $pos); } if (strpos($pos, 'centre') !== FALSE && strpos($pos, 'top') === FALSE && strpos($pos, 'bottom') === FALSE) { $pos = str_replace('centre', 'top', $pos); } $pos = 'outside ' . $pos; return $pos; }
/** * Overload to flip axes */ protected function LabelAdjustment($longest_v = 1000, $longest_h = 100) { parent::LabelAdjustment($longest_h, $longest_v); }
/** * Slightly less restrictive than the radar graph */ protected function CheckValues(&$values) { GridGraph::CheckValues($values); if ($this->GetHorizontalCount() < 2) { throw new Exception('Not enough values for line graph'); } if ($this->multi_graph->GetMinValue() < 0) { throw new Exception('Negative value for radar graph'); } }