/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); reset($this->_dataset); if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } $p1 = false; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); $numPoints = 0; while ($point = $dataset->_next()) { if ($this->_multiType == 'stacked' || $this->_multiType == 'stacked100pct') { $x = $point['X']; if (!isset($current[$x])) { $current[$x] = 0; } if ($this->_multiType == 'stacked') { $py = $current[$x] + $point['Y']; } else { $py = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]; } $current[$x] += $point['Y']; $point['Y'] = $py; } if ($point['Y'] === null) { if ($numPoints > 1) { $this->_getLineStyle($key); $this->_canvas->polygon(array('connect' => false, 'map_vertices' => true)); } $numPoints = 0; } else { $p2['X'] = $this->_pointX($point); $p2['Y'] = $this->_pointY($point); $this->_canvas->addVertex($this->_mergeData($point, array('x' => $p2['X'], 'y' => $p2['Y']))); $numPoints++; } } if ($numPoints > 1) { $this->_getLineStyle($key); $this->_canvas->polygon(array('connect' => false, 'map_vertices' => true)); } } unset($keys); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (Image_Graph_Plot::_done() === false) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Output the plot * @access private */ function _done() { parent::_done(); $p1 = false; $this->_dataset->_reset(); while ($point = $this->_dataset->_next()) { $p2['X'] = $this->_parent->_pointX($point); $p2['Y'] = $this->_parent->_pointY($point); if ($p1) { ImageLine($this->_canvas(), $p1['X'], $p1['Y'], $p2['X'], $p2['Y'], $this->_getLineStyle()); } $p1 = $p2; } $this->_drawMarker(); }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (Image_Graph_Plot::_done() === false) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); $data = array(); while ($point = $dataset->_next()) { $data[] = array('X' => $this->_pointX($point), 'Y' => $this->_pointY($point)); } $regression = Image_Graph_Tool::calculateLinearRegression($data); $this->_getLineStyle($key); $this->_canvas->line(array('x0' => $this->_left, 'y0' => $this->_left * $regression['slope'] + $regression['intersection'], 'x1' => $this->_right, 'y1' => $this->_right * $regression['slope'] + $regression['intersection'])); } $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $current = array(); $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); $upperBand = array(); $lowerBand = array(); while ($data = $dataset->_next()) { if ($this->_parent->_horizontal) { $point['X'] = $data['X']; $point['Y'] = $data['Y']['high']; $y = $this->_pointY($point); $x_high = $this->_pointX($point); $point['Y'] = $data['Y']['low']; $x_low = $this->_pointX($point); $data = array('X' => $x_high, 'Y' => $y); if (isset($point['data'])) { $data['data'] = $point['data']; } else { $data['data'] = array(); } $upperBand[] = $data; $data = array('X' => $x_low, 'Y' => $y); if (isset($point['data'])) { $data['data'] = $point['data']; } else { $data['data'] = array(); } $lowerBand[] = $data; } else { $point['X'] = $data['X']; $y = $data['Y']; $point['Y'] = $data['Y']['high']; $x = $this->_pointX($point); $y_high = $this->_pointY($point); $point['Y'] = $data['Y']['low']; $y_low = $this->_pointY($point); $data = array('X' => $x, 'Y' => $y_high); if (isset($point['data'])) { $data['data'] = $point['data']; } else { $data['data'] = array(); } $upperBand[] = $data; $data = array('X' => $x, 'Y' => $y_low); if (isset($point['data'])) { $data['data'] = $point['data']; } else { $data['data'] = array(); } $lowerBand[] = $data; } } $lowerBand = array_reverse($lowerBand); foreach ($lowerBand as $point) { $this->_canvas->addVertex($this->_mergeData($point['data'], array('x' => $point['X'], 'y' => $point['Y']))); } foreach ($upperBand as $point) { $this->_canvas->addVertex($this->_mergeData($point['data'], array('x' => $point['X'], 'y' => $point['Y']))); } unset($upperBand); unset($lowerBand); $this->_getLineStyle($key); $this->_getFillStyle($key); $this->_canvas->polygon(array('connect' => true, 'map_vertices' => true)); } unset($keys); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_clip(true); if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) { $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $maxY = $dataset->maximumY(); $count = $dataset->count(); $dataset->_reset(); while ($point = $dataset->_next()) { $this->_canvas->addVertex(array('x' => $this->_pointX($point), 'y' => $this->_pointY($point))); } $this->_getFillStyle($key); $this->_getLineStyle($key); $this->_canvas->polygon(array('connect' => true)); } unset($keys); } $this->_drawMarker(); $this->_clip(false); $this->_canvas->endGroup(); return parent::_done(); }
/** * Set the extrema of the axis * * @param Image_Graph_Plot $plot The plot that 'hold' the values * @access private */ function _setExtrema(&$plot) { if ($this->_axisX != null && $this->_axisX->_isNumeric()) { $this->_axisX->_setMinimum($plot->_minimumX()); $this->_axisX->_setMaximum($plot->_maximumX()); } if ($plot->_axisY == IMAGE_GRAPH_AXIS_Y_SECONDARY && $this->_axisYSecondary !== null && $this->_axisYSecondary->_isNumeric()) { $this->_axisYSecondary->_setMinimum($plot->_minimumY()); $this->_axisYSecondary->_setMaximum($plot->_maximumY()); } elseif ($this->_axisY != null && $this->_axisY->_isNumeric()) { $this->_axisY->_setMinimum($plot->_minimumY()); $this->_axisY->_setMaximum($plot->_maximumY()); } $datasets =& $plot->dataset(); if (!is_array($datasets)) { $datasets = array($datasets); } $keys = array_keys($datasets); foreach ($keys as $key) { $dataset =& $datasets[$key]; if ($dataset->count() > 0) { $this->_hasData = true; } if (is_a($dataset, 'Image_Graph_Dataset')) { if ($this->_axisX != null && !$this->_axisX->_isNumeric()) { $this->_axisX->_applyDataset($dataset); } if ($plot->_axisY == IMAGE_GRAPH_AXIS_Y_SECONDARY && $this->_axisYSecondary !== null && !$this->_axisYSecondary->_isNumeric()) { $this->_axisYSecondary->_applyDataset($dataset); } elseif ($this->_axisY != null && !$this->_axisY->_isNumeric()) { $this->_axisY->_applyDataset($dataset); } } } unset($keys); }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_clip(true); if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } $current = array(); $number = 0; $minYaxis = $this->_parent->_getMinimum($this->_axisY); $maxYaxis = $this->_parent->_getMaximum($this->_axisY); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); while ($point = $dataset->_next()) { $x0 = $this->_pointX($point); if ($this->_multiType == 'stacked' || $this->_multiType == 'stacked100pct') { $x = $point['X']; if ($point['Y'] >= 0) { if (!isset($current[$x])) { $current[$x] = 0; } if ($this->_multiType == 'stacked') { $p0 = array('X' => $point['X'], 'Y' => $current[$x]); $p1 = array('X' => $point['X'], 'Y' => $current[$x] + $point['Y']); } else { $p0 = array('X' => $point['X'], 'Y' => 100 * $current[$x] / $total['TOTAL_Y'][$x]); $p1 = array('X' => $point['X'], 'Y' => 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]); } $current[$x] += $point['Y']; } else { if (!isset($currentNegative[$x])) { $currentNegative[$x] = 0; } $p0 = array('X' => $point['X'], 'Y' => $currentNegative[$x]); $p1 = array('X' => $point['X'], 'Y' => $currentNegative[$x] + $point['Y']); $currentNegative[$x] += $point['Y']; } } else { $p0 = array('X' => $point['X'], 'Y' => 0); $p1 = $point; } if (($minY = min($p0['Y'], $p1['Y'])) < $maxYaxis && ($maxY = max($p0['Y'], $p1['Y'])) > $minYaxis) { $p0['Y'] = $minY; $p1['Y'] = $maxY; if ($p0['Y'] < $minYaxis) { $p0['Y'] = '#min_pos#'; } if ($p1['Y'] > $maxYaxis) { $p1['Y'] = '#max_neg#'; } $x1 = $this->_pointX($p0); $y1 = $this->_pointY($p0); $x2 = $this->_pointX($p1); $y2 = $this->_pointY($p1); if ($this->_multiType == 'normal') { $offset = 5 * $number; $x1 += $offset; $x2 += $offset; } $ID = $point['ID']; if ($ID === false && count($this->_dataset) > 1) { $ID = $key; } $this->_getLineStyle($key); $this->_canvas->line($this->_mergeData($point, array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2))); } } $number++; } unset($keys); $this->_clip(false); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (Image_Graph_Plot::_done() === false) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_clip(true); if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } if ($this->_parent->_horizontal) { $width = $this->height() / ($this->_maximumX() + 2) / 2; } else { $width = $this->width() / ($this->_maximumX() + 2) / 2; } reset($this->_dataset); $key = key($this->_dataset); $dataset =& $this->_dataset[$key]; $first = $dataset->first(); $last = $dataset->last(); $point = array('X' => $first['X'], 'Y' => '#min_pos#'); $firstY = $this->_pointY($point) + ($this->_parent->_horizontal ? $width : 0); $base[] = $firstY; $firstX = $this->_pointX($point) - ($this->_parent->_horizontal ? 0 : $width); $base[] = $firstX; $point = array('X' => $last['X'], 'Y' => '#min_pos#'); $base[] = $this->_pointY($point) - ($this->_parent->_horizontal ? $width : 0); $base[] = $this->_pointX($point) + ($this->_parent->_horizontal ? 0 : $width); $first = $this->_parent->_horizontal ? $firstY : $firstX; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); $polygon = array_reverse($base); unset($base); $last = $first; while ($point = $dataset->_next()) { $x = $point['X']; $p = $point; if (!isset($current[$x])) { $current[$x] = 0; } if ($this->_multiType == 'stacked100pct') { $p['Y'] = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]; } else { $p['Y'] += $current[$x]; } $current[$x] += $point['Y']; $point = $p; if ($this->_parent->_horizontal) { $x0 = $this->_pointX($point); $y0 = $last; $x1 = $this->_pointX($point); $last = $y1 = $this->_pointY($point) - $width; } else { $x0 = $last; $y0 = $this->_pointY($point); $last = $x1 = $this->_pointX($point) + $width; $y1 = $this->_pointY($point); } $polygon[] = $x0; $base[] = $y0; $polygon[] = $y0; $base[] = $x0; $polygon[] = $x1; $base[] = $y1; $polygon[] = $y1; $base[] = $x1; } while (list(, $x) = each($polygon)) { list(, $y) = each($polygon); $this->_canvas->addVertex(array('x' => $x, 'y' => $y)); } $this->_getFillStyle($key); $this->_getLineStyle($key); $this->_canvas->polygon(array('connect' => true)); } unset($keys); $this->_drawMarker(); $this->_clip(false); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } $current = array(); $number = 0; $width = floor(0.5 * $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2); if ($this->_whiskerSize !== false) { $r = $this->_whiskerSize; } else { $r = min(5, $width / 10); } $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); while ($data = $dataset->_next()) { if ($this->_parent->_horizontal) { $point['X'] = $data['X']; $y = $data['Y']; $min = min($y); $max = max($y); $q1 = $dataset->_median($y, 'first'); $med = $dataset->_median($y, 'second'); $q3 = $dataset->_median($y, 'third'); $point['Y'] = $min; $y = $this->_pointY($point); $x_min = $this->_pointX($point); $point['Y'] = $max; $x_max = $this->_pointX($point); $point['Y'] = $q1; $x_q1 = $this->_pointX($point); $point['Y'] = $med; $x_med = $this->_pointX($point); $point['Y'] = $q3; $x_q3 = $this->_pointX($point); $this->_drawBoxWhiskerH($y, $width, $r, $x_min, $x_q1, $x_med, $x_q3, $x_max, $key); } else { $point['X'] = $data['X']; $y = $data['Y']; $min = min($y); $max = max($y); $q1 = $dataset->_median($y, 'first'); $med = $dataset->_median($y, 'second'); $q3 = $dataset->_median($y, 'third'); $point['Y'] = $min; $x = $this->_pointX($point); $y_min = $this->_pointY($point); $point['Y'] = $max; $y_max = $this->_pointY($point); $point['Y'] = $q1; $y_q1 = $this->_pointY($point); $point['Y'] = $med; $y_med = $this->_pointY($point); $point['Y'] = $q3; $y_q3 = $this->_pointY($point); $this->_drawBoxWhiskerV($x, $width, $r, $y_min, $y_q1, $y_med, $y_q3, $y_max, $key); } } } unset($keys); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Calculate marker point data * * @param array $point The point to calculate data for * @param array $nextPoint The next point * @param array $prevPoint The previous point * @param array $totals The pre-calculated totals, if needed * @return array An array containing marker point data * @access private */ function _getMarkerData($point, $nextPoint, $prevPoint, &$totals) { $point = parent::_getMarkerData($point, $nextPoint, $prevPoint, $totals); $point['ANGLE'] = $this->_value2angle($point['Y']); $point['ANG_X'] = cos(deg2rad($point['ANGLE'])); $point['ANG_Y'] = sin(deg2rad($point['ANGLE'])); $point['AX'] = -$point['ANG_X']; $point['AY'] = -$point['ANG_Y']; $point['LENGTH'] = 2.5; //$radius; $point['MARKER_X'] = $totals['CENTER_X'] + $totals['ODO_RADIUS'] * $point['ANG_X']; $point['MARKER_Y'] = $totals['CENTER_Y'] + $totals['ODO_RADIUS'] * $point['ANG_Y']; return $point; }
/** * Return the maximum Y point * * @return double The maximum Y point * @access private */ function _maximumY() { return 1.05 * parent::_maximumY(); }
/** * PlotTypeMultipleData [Constructor] * @param array $datasets The datasets to plot */ function &Image_Graph_Plot_MultipleData($datasets) { parent::__construct(); $this->_datasets = $datasets; }
/** * Output the plot * @access private */ function _done() { parent::_done(); if ($this->_dataset) { if (!$this->_xValueWidth) { $width = ($this->width() / ($this->_dataset->count() + 2)) / 2; } $this->_dataset->_reset(); while ($point = $this->_dataset->_next()) { if (!$this->_xValueWidth) { $x1 = $this->_parent->_pointX($point) - $width + $this->_space; $x2 = $this->_parent->_pointX($point) + $width - $this->_space; } else { $x1 = $this->_parent->_pointX($point['X'] - $this->_xValueWidth / 2) + $this->_space; $x2 = $this->_parent->_pointX($point['X'] + $this->_xValueWidth / 2) - $this->_space; } $y1 = $this->_parent->_pointY(0); $y2 = $this->_parent->_pointY($point); ImageFilledRectangle($this->_canvas(), min($x1, $x2), min($y1, $y2), max($x1, $x2), max($y1, $y2), $this->_getFillStyle()); ImageRectangle($this->_canvas(), min($x1, $x2), min($y1, $y2), max($x1, $x2), max($y1, $y2), $this->_getLineStyle()); } $this->_drawMarker(); } }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $base = array(); if ($this->_multiType == 'stacked') { reset($this->_dataset); $key = key($this->_dataset); $dataset =& $this->_dataset[$key]; $first = $dataset->first(); $point = array('X' => $first['X'], 'Y' => '#min_pos#'); $base[] = array(); $base[] = $this->_pointY($point); $first = $this->_pointX($point); $base[] = $first; $last = $dataset->last(); $point = array('X' => $last['X'], 'Y' => '#min_pos#'); $base[] = array(); $base[] = $this->_pointY($point); $base[] = $this->_pointX($point); $current = array(); } $minYaxis = $this->_parent->_getMinimum($this->_axisY); $maxYaxis = $this->_parent->_getMaximum($this->_axisY); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); if ($this->_multiType == 'stacked') { $plotarea = array_reverse($base); $base = array(); while ($point = $dataset->_next()) { $x = $point['X']; $p = $point; if (isset($current[$x])) { $p['Y'] += $current[$x]; } else { $current[$x] = 0; } $x1 = $this->_pointX($p); $y1 = $this->_pointY($p); $plotarea[] = $x1; $plotarea[] = $y1; $plotarea[] = $point; $base[] = array(); $base[] = $y1; $base[] = $x1; $current[$x] += $point['Y']; } } else { $first = true; $plotarea = array(); while ($point = $dataset->_next()) { if ($first) { $firstPoint = array('X' => $point['X'], 'Y' => '#min_pos#'); $plotarea[] = $this->_pointX($firstPoint); $plotarea[] = $this->_pointY($firstPoint); $plotarea[] = array(); } $plotarea[] = $this->_pointX($point); $plotarea[] = $this->_pointY($point); $plotarea[] = $point; $lastPoint = $point; $first = false; } $endPoint['X'] = $lastPoint['X']; $endPoint['Y'] = '#min_pos#'; $plotarea[] = $this->_pointX($endPoint); $plotarea[] = $this->_pointY($endPoint); $plotarea[] = array(); } reset($plotarea); while (list(, $x) = each($plotarea)) { list(, $y) = each($plotarea); list(, $data) = each($plotarea); $this->_canvas->addVertex($this->_mergeData($data, array('x' => $x, 'y' => $y))); } $this->_getFillStyle($key); $this->_getLineStyle($key); $this->_canvas->polygon(array('connect' => true, 'map_vertices' => true)); } unset($keys); $this->_drawMarker(); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_clip(true); if ($this->_width == 'auto') { $width = $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2; } elseif ($this->_width['unit'] == '%') { $width = $this->_width['width'] * $this->width() / 200; } elseif ($this->_width['unit'] == 'px') { $width = $this->_width['width'] / 2; } if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } $minYaxis = $this->_parent->_getMinimum($this->_axisY); $maxYaxis = $this->_parent->_getMaximum($this->_axisY); $number = 0; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); while ($point = $dataset->_next()) { if ($this->_parent->_horizontal) { $y1 = $this->_pointY($point) - $width; $y2 = $this->_pointY($point) + $width; if ($y2 - $this->_space > $y1 + $this->_space) { /* * Take bar spacing into account _only_ if the space doesn't * turn the bar "inside-out", i.e. if the actual bar width * is smaller than the space between the bars */ $y2 -= $this->_space; $y1 += $this->_space; } } else { $x1 = $this->_pointX($point) - $width; $x2 = $this->_pointX($point) + $width; if ($x2 - $this->_space > $x1 + $this->_space) { /* * Take bar spacing into account _only_ if the space doesn't * turn the bar "inside-out", i.e. if the actual bar width * is smaller than the space between the bars */ $x2 -= $this->_space; $x1 += $this->_space; } } if ($this->_multiType == 'stacked' || $this->_multiType == 'stacked100pct') { $x = $point['X']; if ($point['Y'] >= 0) { if (!isset($current[$x])) { $current[$x] = 0; } if ($this->_multiType == 'stacked') { $p0 = array('X' => $point['X'], 'Y' => $current[$x]); $p1 = array('X' => $point['X'], 'Y' => $current[$x] + $point['Y']); } else { $p0 = array('X' => $point['X'], 'Y' => 100 * $current[$x] / $total['TOTAL_Y'][$x]); $p1 = array('X' => $point['X'], 'Y' => 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]); } $current[$x] += $point['Y']; } else { if (!isset($currentNegative[$x])) { $currentNegative[$x] = 0; } $p0 = array('X' => $point['X'], 'Y' => $currentNegative[$x]); $p1 = array('X' => $point['X'], 'Y' => $currentNegative[$x] + $point['Y']); $currentNegative[$x] += $point['Y']; } } else { if (count($this->_dataset) > 1) { $w = 2 * ($width - $this->_space) / count($this->_dataset); if ($this->_parent->_horizontal) { $y2 = ($y1 = ($y1 + $y2) / 2 - ($width - $this->_space) + $number * $w) + $w; } else { $x2 = ($x1 = ($x1 + $x2) / 2 - ($width - $this->_space) + $number * $w) + $w; } } $p0 = array('X' => $point['X'], 'Y' => 0); $p1 = $point; } if (($minY = min($p0['Y'], $p1['Y'])) < $maxYaxis && ($maxY = max($p0['Y'], $p1['Y'])) > $minYaxis) { $p0['Y'] = $minY; $p1['Y'] = $maxY; if ($p0['Y'] < $minYaxis) { $p0['Y'] = '#min_pos#'; } if ($p1['Y'] > $maxYaxis) { $p1['Y'] = '#max_neg#'; } if ($this->_parent->_horizontal) { $x1 = $this->_pointX($p0); $x2 = $this->_pointX($p1); } else { $y1 = $this->_pointY($p0); $y2 = $this->_pointY($p1); } $ID = $point['ID']; if ($ID === false && count($this->_dataset) > 1) { $ID = $key; } $this->_getFillStyle($ID); $this->_getLineStyle($ID); if ($y1 != $y2 && $x1 != $x2) { $this->_canvas->rectangle($this->_mergeData($point, array('x0' => min($x1, $x2), 'y0' => min($y1, $y2), 'x1' => max($x1, $x2), 'y1' => max($y1, $y2)))); } } } $number++; } unset($keys); $this->_drawMarker(); $this->_clip(false); $this->_canvas->endGroup(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } $number = 0; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $totalY = 0; $dataset->_reset(); while ($point = $dataset->_next()) { $totalY += $point['Y']; } $centerX = (int) (($this->_left + $this->_right) / 2); $centerY = (int) (($this->_top + $this->_bottom) / 2); $diameter = $this->_getDiameter(); if ($this->_angleDirection < 0) { $currentY = $totalY; } else { $currentY = 0; //rand(0, 100)*$totalY/100; } $dataset->_reset(); if (count($this->_dataset) == 1) { $radius0 = false; $radius1 = $diameter / 2; } else { $dr = $diameter / (2 * count($this->_dataset)); $radius0 = $number * $dr + ($number > 0 ? $this->_radius : 0); $radius1 = ($number + 1) * $dr; } $the_rest = 0; while ($point = $dataset->_next()) { if ($this->_restGroupLimit !== false && $point['Y'] <= $this->_restGroupLimit) { $the_rest += $point['Y']; } else { $angle1 = 360 * ($currentY / $totalY) + $this->_startingAngle; $currentY += $this->_angleDirection * $point['Y']; $angle2 = 360 * ($currentY / $totalY) + $this->_startingAngle; $x = $point['X']; $id = $point['ID']; $dX = 0; $dY = 0; $explodeRadius = 0; if (is_array($this->_explode) && isset($this->_explode[$x])) { $explodeRadius = $this->_explode[$x]; } elseif (is_numeric($this->_explode)) { $explodeRadius = $this->_explode; } if ($explodeRadius > 0) { $dX = $explodeRadius * cos(deg2rad(($angle1 + $angle2) / 2)); $dY = $explodeRadius * sin(deg2rad(($angle1 + $angle2) / 2)); } $ID = $point['ID']; $this->_getFillStyle($ID); $this->_getLineStyle($ID); $this->_canvas->pieslice($this->_mergeData($point, array('x' => $centerX + $dX, 'y' => $centerY + $dY, 'rx' => $radius1, 'ry' => $radius1, 'v1' => $angle1, 'v2' => $angle2, 'srx' => $radius0, 'sry' => $radius0))); } } if ($the_rest > 0) { $angle1 = 360 * ($currentY / $totalY) + $this->_startingAngle; $currentY += $this->_angleDirection * $the_rest; $angle2 = 360 * ($currentY / $totalY) + $this->_startingAngle; $x = 'rest'; $id = 'rest'; $dX = 0; $dY = 0; $explodeRadius = 0; if (is_array($this->_explode) && isset($this->_explode[$x])) { $explodeRadius = $this->_explode[$x]; } elseif (is_numeric($this->_explode)) { $explodeRadius = $this->_explode; } if ($explodeRadius > 0) { $dX = $explodeRadius * cos(deg2rad(($angle1 + $angle2) / 2)); $dY = $explodeRadius * sin(deg2rad(($angle1 + $angle2) / 2)); } $ID = $id; $this->_getFillStyle($ID); $this->_getLineStyle($ID); $this->_canvas->pieslice($this->_mergeData($point, array('x' => $centerX + $dX, 'y' => $centerY + $dY, 'rx' => $radius1, 'ry' => $radius1, 'v1' => $angle1, 'v2' => $angle2, 'srx' => $radius0, 'sry' => $radius0))); } $number++; } unset($keys); $this->_drawMarker(); return true; }
/** * Output the plot * * @return bool Was the output 'good' (true) or 'bad' (false). * @access private */ function _done() { if (parent::_done() === false) { return false; } if (!is_array($this->_dataset)) { return false; } $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); $this->_clip(true); if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } $current = array(); $number = 0; $width = floor(0.8 * $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2); $lastClosed = false; $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); while ($data = $dataset->_next()) { if ($this->_parent->_horizontal) { $point['X'] = $data['X']; //$y = $data['Y']; if (isset($data['Y']['open'])) { $point['Y'] = $data['Y']['open']; } else { $point['Y'] = $lastClosed; } $y = $this->_pointY($point); $x_open = $this->_pointX($point); $lastClosed = $point['Y'] = $data['Y']['close']; $x_close = $this->_pointX($point); $point['Y'] = $data['Y']['min']; $x_min = $this->_pointX($point); $point['Y'] = $data['Y']['max']; $x_max = $this->_pointX($point); if ($data['Y']['close'] < $data['Y']['open']) { $ID = 'red'; } else { $ID = 'green'; } $this->_drawCandleStickH($y, $width, $x_min, $x_open, $x_close, $x_max, $ID); } else { $point['X'] = $data['X']; //$y = $data['Y']; if (isset($data['Y']['open'])) { $point['Y'] = $data['Y']['open']; } else { $point['Y'] = $lastClosed; } $x = $this->_pointX($point); $y_open = $this->_pointY($point); $lastClosed = $point['Y'] = $data['Y']['close']; $y_close = $this->_pointY($point); $point['Y'] = $data['Y']['min']; $y_min = $this->_pointY($point); $point['Y'] = $data['Y']['max']; $y_max = $this->_pointY($point); if ($data['Y']['close'] < $data['Y']['open']) { $ID = 'red'; } else { $ID = 'green'; } $this->_drawCandleStickV($x, $width, $y_min, $y_open, $y_close, $y_max, $ID); } } } unset($keys); $this->_drawMarker(); $this->_clip(false); $this->_canvas->endGroup($this->_title); return true; }
/** * Output the plot * @access private */ function _done() { parent::_done(); $totalY = 0; $this->_dataset->_reset(); while ($point = $this->_dataset->_next()) { $totalY += $point['Y']; } $centerX = (int) (($this->_left + $this->_right) / 2); $centerY = (int) (($this->_top + $this->_bottom) / 2); $diameter = min($this->height(), $this->width()) * 0.75; $currentY = 0; //rand(0, 100)*$totalY/100; $this->_dataset->_reset(); while ($point = $this->_dataset->_next()) { $angle1 = 360 * ($currentY / $totalY); $currentY += $point['Y']; $angle2 = 360 * ($currentY / $totalY); $dX = $diameter * ($this->_radius / 100) * cos(deg2rad(($angle1 + $angle2) / 2)); $dY = $diameter * ($this->_radius / 100) * sin(deg2rad(($angle1 + $angle2) / 2)); $dD = sqrt($dX * $dX + $dY * $dY); $polygon[] = $centerX; $polygon[] = $centerY; $angle = min($angle1, $angle2); $dA = 360 / (pi() * $diameter); while ($angle <= max($angle1, $angle2)) { $polygon[] = ($centerX + ($diameter / 2) * cos(deg2rad($angle % 360))); $polygon[] = ($centerY + ($diameter / 2) * sin(deg2rad($angle % 360))); $angle += $dA; } if ($angle != max($angle1, $angle2)) { $polygon[] = ($centerX + ($diameter / 2) * cos(deg2rad($angle2 % 360))); $polygon[] = ($centerY + ($diameter / 2) * sin(deg2rad($angle2 % 360))); } //ImageFilledArc($this->_canvas(), $centerX+$dX, $centerY+$dY, $diameter-$dD, $diameter-$dD, $angle1 % 360, $angle2 % 360, $this->_getFillStyle(), IMG_ARC_PIE); //ImageFilledArc($this->_canvas(), $centerX+$dX, $centerY+$dY, $diameter-$dD, $diameter-$dD, $angle1 % 360, $angle2 % 360, $this->_getLineStyle(), IMG_ARC_NOFILL+IMG_ARC_EDGED); ImageFilledPolygon($this->_canvas(), $polygon, count($polygon) / 2, $this->_getFillStyle()); //echo $this->_getFillStyle(); // Modified: Don't draw border //ImagePolygon($this->_canvas(), $polygon, count($polygon) / 2, $this->_getLineStyle()); unset ($polygon); } //ImageEllipse($this->_canvas(), $centerX, $centerY, $diameter, $diameter, 0); $this->_drawMarker(); }