//$this->dbug("x=$x, y0=$y0, y1=$y1 watchdog=$watchdog");
$this->draw_brush($x, $y0, $size, $type, $colour);
-<<<<<<< graphlib.php
- if (isset($this->y_format[$set]['y_axis']) && $this->y_format[$set]['y_axis'] == 'right') {
- $this->calculated['y_plot'][$set][$index] =
- round(($this->y_data[$set][$index] - $this->calculated['y_axis_right']['min'])
- * $this->calculated['y_axis_right']['factor']);
- } else {
- //print "$set $index<br />";
- $this->calculated['y_plot'][$set][$index] =
- round(($this->y_data[$set][$index] - $this->calculated['y_axis_left']['min'])
- * $this->calculated['y_axis_left']['factor']);
- }
-
- }
- }
- }
- //print "factor ".$this->calculated['x_axis']['factor']."<br />";
- //expand_pre($this->calculated['x_plot']);
-
- // calculate bar parameters if bars are to be drawn.
- if ($this->calculated['num_bars']) {
- $xStep = $this->calculated['x_axis']['step'];
- $totalWidth = $this->calculated['x_axis']['step'] - $this->parameter['bar_spacing'];
- $barWidth = $totalWidth / $this->calculated['num_bars'];
-
- $barX = ($barWidth - $totalWidth) / 2; // starting x offset
- for ($i=0; $i < $this->calculated['num_bars']; $i++) {
- $this->calculated['bar_offset_x'][$i] = $barX;
- $barX += $barWidth; // add width of bar to x offset.
- }
- $this->calculated['bar_width'] = $barWidth;
- }
-
-
-}
-
-function init_x_ticks() {
- // get coords for x axis ticks and data plots
- //$xGrid = $this->parameter['x_grid'];
- $xStep = $this->calculated['x_axis']['step'];
- $ticksOffset = $this->parameter['x_offset']; // where to start drawing ticks relative to y axis.
- $gridLeft = $this->calculated['boundary_box']['left'] + ($xStep * $ticksOffset); // grid x start
- $tickX = $gridLeft; // tick x coord
-
- foreach ($this->calculated['x_axis']['text'] as $set => $value) {
- //print "index: $set<br />";
- // x tick value
- $this->calculated['x_axis']['tick_x'][$set] = $tickX;
- // if num ticks is auto then x plot value is same as x tick
- if ($this->parameter['x_axis_gridlines'] == 'auto') $this->calculated['x_plot'][$set] = round($tickX);
- //print $this->calculated['x_plot'][$set].'<br />';
- $tickX += $xStep;
- }
-
- //print "xStep: $xStep <br />";
- // if numeric x axis then calculate x coords for each data point. this is seperate from x ticks.
- $gridX = $gridLeft;
- if (empty($this->calculated['x_axis']['factor'])) {
- $this->calculated['x_axis']['factor'] = 0;
- }
- if (empty($this->calculated['x_axis']['min'])) {
- $this->calculated['x_axis']['min'] = 0;
- }
- $factor = $this->calculated['x_axis']['factor'];
- $min = $this->calculated['x_axis']['min'];
-
- if ($this->parameter['x_axis_gridlines'] != 'auto') {
- foreach ($this->x_data as $index => $x) {
- //print "index: $index, x: $x<br />";
- $offset = $x - $this->calculated['x_axis']['min'];
-
- //$gridX = ($offset * $this->calculated['x_axis']['factor']);
- //print "offset: $offset <br />";
- //$this->calculated['x_plot'][$set] = $gridLeft + ($offset * $this->calculated['x_axis']['factor']);
-
- $this->calculated['x_plot'][$index] = $gridLeft + ($x - $min) * $factor;
-
- //print $this->calculated['x_plot'][$set].'<br />';
- }
- }
- //expand_pre($this->calculated['boundary_box']);
- //print "factor ".$this->calculated['x_axis']['factor']."<br />";
- //expand_pre($this->calculated['x_plot']);
-}
-
-function init_y_ticks() {
- // get coords for y axis ticks
-
- $yStep = $this->calculated['y_axis']['step'];
- $gridBottom = $this->calculated['boundary_box']['bottom'];
- $tickY = $gridBottom; // tick y coord
-
- for ($i = 0; $i < $this->parameter['y_axis_gridlines']; $i++) {
- $this->calculated['y_axis']['tick_y'][$i] = $tickY;
- $tickY -= $yStep;
- }
-
-}
-
-function init_labels() {
- if ($this->parameter['title']) {
- $size = $this->get_boundaryBox(
- array('points' => $this->parameter['title_size'],
- 'angle' => 0,
- 'font' => $this->parameter['title_font'],
- 'text' => $this->parameter['title']));
- $this->calculated['title']['boundary_box'] = $size;
- $this->calculated['title']['text'] = $this->parameter['title'];
- $this->calculated['title']['font'] = $this->parameter['title_font'];
- $this->calculated['title']['points'] = $this->parameter['title_size'];
- $this->calculated['title']['colour'] = $this->parameter['title_colour'];
- $this->calculated['title']['angle'] = 0;
-
- $this->calculated['boundary_box']['top'] += $size['height'] + $this->parameter['outer_padding'];
- //$this->calculated['boundary_box']['top'] += $size['height'];
-
- } else $this->calculated['title']['boundary_box'] = $this->get_null_size();
-
- if ($this->parameter['y_label_left']) {
- $this->calculated['y_label_left']['text'] = $this->parameter['y_label_left'];
- $this->calculated['y_label_left']['angle'] = $this->parameter['y_label_angle'];
- $this->calculated['y_label_left']['font'] = $this->parameter['label_font'];
- $this->calculated['y_label_left']['points'] = $this->parameter['label_size'];
- $this->calculated['y_label_left']['colour'] = $this->parameter['label_colour'];
-
- $size = $this->get_boundaryBox($this->calculated['y_label_left']);
- $this->calculated['y_label_left']['boundary_box'] = $size;
- //$this->calculated['boundary_box']['left'] += $size['width'] + $this->parameter['inner_padding'];
- $this->calculated['boundary_box']['left'] += $size['width'];
-
- } else $this->calculated['y_label_left']['boundary_box'] = $this->get_null_size();
-
- if ($this->parameter['y_label_right']) {
- $this->calculated['y_label_right']['text'] = $this->parameter['y_label_right'];
- $this->calculated['y_label_right']['angle'] = $this->parameter['y_label_angle'];
- $this->calculated['y_label_right']['font'] = $this->parameter['label_font'];
- $this->calculated['y_label_right']['points'] = $this->parameter['label_size'];
- $this->calculated['y_label_right']['colour'] = $this->parameter['label_colour'];
-
- $size = $this->get_boundaryBox($this->calculated['y_label_right']);
- $this->calculated['y_label_right']['boundary_box'] = $size;
- //$this->calculated['boundary_box']['right'] -= $size['width'] + $this->parameter['inner_padding'];
- $this->calculated['boundary_box']['right'] -= $size['width'];
-
- } else $this->calculated['y_label_right']['boundary_box'] = $this->get_null_size();
-
- if ($this->parameter['x_label']) {
- $this->calculated['x_label']['text'] = $this->parameter['x_label'];
- $this->calculated['x_label']['angle'] = $this->parameter['x_label_angle'];
- $this->calculated['x_label']['font'] = $this->parameter['label_font'];
- $this->calculated['x_label']['points'] = $this->parameter['label_size'];
- $this->calculated['x_label']['colour'] = $this->parameter['label_colour'];
-
- $size = $this->get_boundaryBox($this->calculated['x_label']);
- $this->calculated['x_label']['boundary_box'] = $size;
- //$this->calculated['boundary_box']['bottom'] -= $size['height'] + $this->parameter['inner_padding'];
- $this->calculated['boundary_box']['bottom'] -= $size['height'];
-
- } else $this->calculated['x_label']['boundary_box'] = $this->get_null_size();
-
-}
-
-
-function init_legend() {
- $this->calculated['legend'] = array(); // array to hold calculated values for legend.
- //$this->calculated['legend']['boundary_box_max'] = array('height' => 0, 'width' => 0);
- $this->calculated['legend']['boundary_box_max'] = $this->get_null_size();
- if ($this->parameter['legend'] == 'none') return;
-
- $position = $this->parameter['legend'];
- $numSets = 0; // number of data sets with legends.
- $sumTextHeight = 0; // total of height of all legend text items.
- $width = 0;
- $height = 0;
-
- foreach ($this->y_order as $set) {
- $text = isset($this->y_format[$set]['legend']) ? $this->y_format[$set]['legend'] : 'none';
- $size = $this->get_boundaryBox(
- array('points' => $this->parameter['legend_size'],
- 'angle' => 0,
- 'font' => $this->parameter['legend_font'],
- 'text' => $text));
-
- $this->calculated['legend']['boundary_box'][$set] = $size;
- $this->calculated['legend']['text'][$set] = $text;
- //$this->calculated['legend']['font'][$set] = $this->parameter['legend_font'];
- //$this->calculated['legend']['points'][$set] = $this->parameter['legend_size'];
- //$this->calculated['legend']['angle'][$set] = 0;
-
- if ($text && $text!='none') {
- $numSets++;
- $sumTextHeight += $size['height'];
- }
-
- if ($size['width'] > $this->calculated['legend']['boundary_box_max']['width'])
- $this->calculated['legend']['boundary_box_max'] = $size;
- }
-
- $offset = $this->parameter['legend_offset']; // offset in pixels of legend box from graph border.
- $padding = $this->parameter['legend_padding']; // padding in pixels around legend text.
- $textWidth = $this->calculated['legend']['boundary_box_max']['width']; // width of largest legend item.
- $textHeight = $this->calculated['legend']['boundary_box_max']['height']; // use height as size to use for colour square in legend.
- $width = $padding * 2 + $textWidth + $textHeight * 2; // left and right padding + maximum text width + space for square
- $height = $padding * ($numSets + 1) + $sumTextHeight; // top and bottom padding + padding between text + text.
-
-
- $this->calculated['legend']['boundary_box_all'] = array('width' => $width,
- 'height' => $height,
- 'offset' => $offset,
- 'reference' => $position);
-
- switch ($position) { // move in right or bottom if legend is outside data plotting area.
- case 'outside-top' :
- $this->calculated['boundary_box']['right'] -= $offset + $width; // move in right hand side
- break;
-
- case 'outside-bottom' :
- $this->calculated['boundary_box']['right'] -= $offset + $width; // move in right hand side
- break;
-
- case 'outside-left' :
- $this->calculated['boundary_box']['bottom'] -= $offset + $height; // move in right hand side
- break;
-
- case 'outside-right' :
- $this->calculated['boundary_box']['bottom'] -= $offset + $height; // move in right hand side
- break;
- }
-}
-
-function init_y_axis() {
- $this->calculated['y_axis_left'] = array(); // array to hold calculated values for y_axis on left.
- $this->calculated['y_axis_left']['boundary_box_max'] = $this->get_null_size();
- $this->calculated['y_axis_right'] = array(); // array to hold calculated values for y_axis on right.
- $this->calculated['y_axis_right']['boundary_box_max'] = $this->get_null_size();
-
- $axis_font = $this->parameter['axis_font'];
- $axis_size = $this->parameter['axis_size'];
- $axis_colour = $this->parameter['axis_colour'];
- $axis_angle = $this->parameter['y_axis_angle'];
- $y_tick_labels = $this->parameter['y_tick_labels'];
-
- $this->calculated['y_axis_left']['has_data'] = FALSE;
- $this->calculated['y_axis_right']['has_data'] = FALSE;
-
- // find min and max y values.
- $minLeft = $this->parameter['y_min_left'];
- $maxLeft = $this->parameter['y_max_left'];
- $minRight = $this->parameter['y_min_right'];
- $maxRight = $this->parameter['y_max_right'];
- $dataLeft = array();
- $dataRight = array();
- foreach ($this->y_order as $order => $set) {
- if (isset($this->y_format[$set]['y_axis']) && $this->y_format[$set]['y_axis'] == 'right') {
- $this->calculated['y_axis_right']['has_data'] = TRUE;
- $dataRight = array_merge($dataRight, $this->y_data[$set]);
- } else {
- $this->calculated['y_axis_left']['has_data'] = TRUE;
- $dataLeft = array_merge($dataLeft, $this->y_data[$set]);
- }
- }
- $dataLeftRange = $this->find_range($dataLeft, $minLeft, $maxLeft, $this->parameter['y_resolution_left']);
- $dataRightRange = $this->find_range($dataRight, $minRight, $maxRight, $this->parameter['y_resolution_right']);
- $minLeft = $dataLeftRange['min'];
- $maxLeft = $dataLeftRange['max'];
- $minRight = $dataRightRange['min'];
- $maxRight = $dataRightRange['max'];
-
- $this->calculated['y_axis_left']['min'] = $minLeft;
- $this->calculated['y_axis_left']['max'] = $maxLeft;
- $this->calculated['y_axis_right']['min'] = $minRight;
- $this->calculated['y_axis_right']['max'] = $maxRight;
-
- $stepLeft = ($maxLeft - $minLeft) / ($this->parameter['y_axis_gridlines'] - 1);
- $startLeft = $minLeft;
- $step_right = ($maxRight - $minRight) / ($this->parameter['y_axis_gridlines'] - 1);
- $start_right = $minRight;
-
- if ($this->parameter['y_axis_text_left']) {
- for ($i = 0; $i < $this->parameter['y_axis_gridlines']; $i++) { // calculate y axis text sizes
- // left y axis
- if ($y_tick_labels) {
- $value = $y_tick_labels[$i];
- } else {
- $value = number_format($startLeft, $this->parameter['y_decimal_left'], $this->parameter['decimal_point'], $this->parameter['thousand_sep']);
-=======
}
->>>>>>> 1.21
}
}