/** * Draw the marker on the canvas * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas * @param array $values The values representing the data the marker "points" to * @access private */ function _drawMarker($x, $y, $values = false) { parent::_drawMarker($x, $y, $values); if ($this->_markerStart) { $this->_markerStart->_drawMarker($x, $y, $values); } // Modified: Don't draw pointer if line thickness is zero if ($this->_getLineStyle() != 0) ImageLine($this->_canvas(), $x, $y, $x + $this->_deltaX, $y + $this->_deltaY, $this->_getLineStyle()); $this->_markerEnd->_drawMarker($x + $this->_deltaX, $y + $this->_deltaY, $values); }
/** * Draw the marker on the canvas * * @param int $x The X (horizontal) position (in pixels) of the marker on * the canvas * @param int $y The Y (vertical) position (in pixels) of the marker on the * canvas * @param array $values The values representing the data the marker 'points' * to * @access private */ function _drawMarker($x, $y, $values = false) { parent::_drawMarker($x, $y, $values); if ($this->_markerStart) { $this->_markerStart->_setParent($this); $this->_markerStart->_drawMarker($x, $y, $values); } $this->_getLineStyle(); $this->_canvas->line(array('x0' => $x, 'y0' => $y, 'x1' => $x + $this->_deltaX, 'y1' => $y + $this->_deltaY)); $this->_markerEnd->_setParent($this); $this->_markerEnd->_drawMarker($x + $this->_deltaX, $y + $this->_deltaY, $values); }
/** * Draw a sample for use with legend * @param int $x The x coordinate to draw the sample at * @param int $y The y coordinate to draw the sample at * @access private */ function _legendSample($x, $y, &$font) { if (is_a($this->_fillStyle, "Image_Graph_Fill")) { $fillStyle = $this->_fillStyle->_getFillStyleAt($x -5, $y -5, 10, 10); } else { $fillStyle = $this->_getFillStyle(); } if ($fillStyle != IMG_COLOR_TRANSPARENT) { ImageFilledRectangle($this->_canvas(), $x -5, $y -5, $x +5, $y +5, $fillStyle); ImageRectangle($this->_canvas(), $x -5, $y -5, $x +5, $y +5, $this->_getLineStyle()); } else { ImageLine($this->_canvas(), $x -7, $y, $x +7, $y, $this->_getLineStyle()); } if (($this->_marker) and ($this->_dataset)) { $this->_dataset->_reset(); $point = $this->_dataset->_next(); $prevPoint = $this->_dataset->_nearby(-2); $nextPoint = $this->_dataset->_nearby(); $point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $i); if (is_array($point)) { $point['MARKER_X'] = $x; $point['MARKER_Y'] = $y; unset ($point['AVERAGE_Y']); $this->_marker->_drawMarker($point['MARKER_X'], $point['MARKER_Y'], $point); } } $text = new Image_Graph_Text($x + 20, $y, $this->_title, $font); $text->setAlignment(IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT); $this->add($text); $text->_done(); return array('Width' => 20+$font->width($this->_title), 'Height' => max(10, $font->height($this->_title))); }
/** * Draw a sample for use with legend * * @param array &$param The parameters for the legend * * @return void * @access private */ function _legendSample(&$param) { if (!is_array($this->_dataset)) { return false; } if (is_a($this->_fillStyle, 'Image_Graph_Fill')) { $this->_fillStyle->_reset(); } $count = 0; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $count++; $caption = $dataset->_name ? $dataset->_name : $this->_title; $this->_canvas->setFont($param['font']); $width = 20 + $param['width'] + $this->_canvas->textWidth($caption); $param['maxwidth'] = max($param['maxwidth'], $width); $x2 = $param['x'] + $width; $y2 = $param['y'] + $param['height'] + 5; if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0 && $y2 > $param['bottom']) { $param['y'] = $param['top']; $param['x'] = $x2; $y2 = $param['y'] + $param['height']; } elseif (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) == 0 && $x2 > $param['right']) { $param['x'] = $param['left']; $param['y'] = $y2; $x2 = $param['x'] + 20 + $param['width'] + $this->_canvas->textWidth($caption); } $x = $x0 = $param['x']; $y = $param['y']; $y0 = $param['y']; $x1 = $param['x'] + $param['width']; $y1 = $param['y'] + $param['height']; if (!isset($param['simulate'])) { $this->_getFillStyle($key); $this->_getLineStyle(); $this->_drawLegendSample($x0, $y0, $x1, $y1); if ($this->_marker && $dataset && $param['show_marker']) { $dataset->_reset(); $point = $dataset->_next(); $prevPoint = $dataset->_nearby(-2); $nextPoint = $dataset->_nearby(); $tmp = array(); $point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $tmp); if (is_array($point)) { $point['MARKER_X'] = $x + $param['width'] / 2; $point['MARKER_Y'] = $y; unset($point['AVERAGE_Y']); $this->_marker->_drawMarker($point['MARKER_X'], $point['MARKER_Y'], $point); } } $this->write($x + $param['width'] + 10, $y + $param['height'] / 2, $caption, IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT, $param['font']); } if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) { $param['y'] = $y2; } else { $param['x'] = $x2; } } unset($keys); }
/** * Draw the marker on the canvas * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas * @param array $values The values representing the data the marker "points" to * @access private */ function _drawMarker($x, $y, $values = false) { if (is_a($this->_secondaryMarker, "Image_Graph_Marker")) { $this->_secondaryMarker->_drawMarker($x, $y, $values); } }