| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  | require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |  * PHPExcel_Chart_Renderer_jpgraph | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-05-02 22:50:37 +00:00
										 |  |  |  * Copyright (c) 2006 - 2015 PHPExcel | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License along with this library; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |  * @category    PHPExcel | 
					
						
							|  |  |  |  * @package        PHPExcel_Chart_Renderer | 
					
						
							|  |  |  |  * @copyright    Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | 
					
						
							|  |  |  |  * @license        http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | 
					
						
							|  |  |  |  * @version        ##VERSION##, ##DATE##
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | class PHPExcel_Chart_Renderer_jpgraph | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $width    = 640; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $height    = 480; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $colourSet = array( | 
					
						
							|  |  |  |         'mediumpurple1',    'palegreen3',     'gold1',          'cadetblue1', | 
					
						
							|  |  |  |         'darkmagenta',      'coral',          'dodgerblue3',    'eggplant', | 
					
						
							|  |  |  |         'mediumblue',       'magenta',        'sandybrown',     'cyan', | 
					
						
							|  |  |  |         'firebrick1',       'forestgreen',    'deeppink4',      'darkolivegreen', | 
					
						
							|  |  |  |         'goldenrod2' | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $markSet = array( | 
					
						
							|  |  |  |         'diamond'  => MARK_DIAMOND, | 
					
						
							|  |  |  |         'square'   => MARK_SQUARE, | 
					
						
							|  |  |  |         'triangle' => MARK_UTRIANGLE, | 
					
						
							|  |  |  |         'x'        => MARK_X, | 
					
						
							|  |  |  |         'star'     => MARK_STAR, | 
					
						
							|  |  |  |         'dot'      => MARK_FILLEDCIRCLE, | 
					
						
							|  |  |  |         'dash'     => MARK_DTRIANGLE, | 
					
						
							|  |  |  |         'circle'   => MARK_CIRCLE, | 
					
						
							|  |  |  |         'plus'     => MARK_CROSS | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private $chart; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private $graph; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $_plotColour = 0; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private static $_plotMark = 0; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private function formatPointMarker($seriesPlot, $markerID) { | 
					
						
							|  |  |  |         $plotMarkKeys = array_keys(self::$markSet); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (is_null($markerID)) { | 
					
						
							|  |  |  |             //    Use default plot marker (next marker in the series)
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             self::$_plotMark %= count(self::$markSet); | 
					
						
							|  |  |  |             $seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$_plotMark++]]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } elseif ($markerID !== 'none') { | 
					
						
							|  |  |  |             //    Use specified plot marker (if it exists)
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             if (isset(self::$markSet[$markerID])) { | 
					
						
							|  |  |  |                 $seriesPlot->mark->SetType(self::$markSet[$markerID]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 //    If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 self::$_plotMark %= count(self::$markSet); | 
					
						
							|  |  |  |                 $seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$_plotMark++]]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             //    Hide plot marker
 | 
					
						
							|  |  |  |             $seriesPlot->mark->Hide(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesPlot->mark->SetColor(self::$colourSet[self::$_plotColour]); | 
					
						
							|  |  |  |         $seriesPlot->mark->SetFillColor(self::$colourSet[self::$_plotColour]); | 
					
						
							|  |  |  |         $seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return $seriesPlot; | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') { | 
					
						
							|  |  |  |         $datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (!is_null($datasetLabelFormatCode)) { | 
					
						
							|  |  |  |             //    Retrieve any label formatting code
 | 
					
						
							|  |  |  |             $datasetLabelFormatCode = stripslashes($datasetLabelFormatCode); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $testCurrentIndex = 0; | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |         foreach ($datasetLabels as $i => $datasetLabel) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if (is_array($datasetLabel)) { | 
					
						
							|  |  |  |                 if ($rotation == 'bar') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $datasetLabels[$i] = implode(" ", $datasetLabel); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } else { | 
					
						
							|  |  |  |                     $datasetLabel = array_reverse($datasetLabel); | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $datasetLabels[$i] = implode("\n", $datasetLabel); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 //    Format labels according to any formatting code
 | 
					
						
							|  |  |  |                 if (!is_null($datasetLabelFormatCode)) { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             ++$testCurrentIndex; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $datasetLabels; | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |     private function _percentageSumCalculation($groupID, $seriesCount) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         //    Adjust our values to a percentage value across all series in the group
 | 
					
						
							|  |  |  |         for($i = 0; $i < $seriesCount; ++$i) { | 
					
						
							|  |  |  |             if ($i == 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $sumValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $nextValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 foreach ($nextValues as $k => $value) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     if (isset($sumValues[$k])) { | 
					
						
							|  |  |  |                         $sumValues[$k] += $value; | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $sumValues[$k] = $value; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $sumValues; | 
					
						
							|  |  |  |     }    //    function _percentageSumCalculation()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |     private function _percentageAdjustValues($dataValues, $sumValues) { | 
					
						
							|  |  |  |         foreach ($dataValues as $k => $dataValue) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             $dataValues[$k] = $dataValue / $sumValues[$k] * 100; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $dataValues; | 
					
						
							|  |  |  |     }    //    function _percentageAdjustValues()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _getCaption($captionElement) { | 
					
						
							|  |  |  |         //    Read any caption
 | 
					
						
							|  |  |  |         $caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL; | 
					
						
							|  |  |  |         //    Test if we have a title caption to display
 | 
					
						
							|  |  |  |         if (!is_null($caption)) { | 
					
						
							|  |  |  |             //    If we do, it could be a plain string or an array
 | 
					
						
							|  |  |  |             if (is_array($caption)) { | 
					
						
							|  |  |  |                 //    Implode an array to a plain string
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $caption = implode('', $caption); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return $caption; | 
					
						
							|  |  |  |     }    //    function _getCaption()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderTitle() { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $title = $this->_getCaption($this->chart->getTitle()); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (!is_null($title)) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->title->Set($title); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderTitle()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderLegend() { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $legend = $this->chart->getLegend(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (!is_null($legend)) { | 
					
						
							|  |  |  |             $legendPosition = $legend->getPosition(); | 
					
						
							|  |  |  |             $legendOverlay = $legend->getOverlay(); | 
					
						
							|  |  |  |             switch ($legendPosition) { | 
					
						
							|  |  |  |                 case 'r'    : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->legend->SetPos(0.01,0.5,'right','center');    //    right
 | 
					
						
							|  |  |  |                     $this->graph->legend->SetColumns(1); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'l'    : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->legend->SetPos(0.01,0.5,'left','center');    //    left
 | 
					
						
							|  |  |  |                     $this->graph->legend->SetColumns(1); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 't'    : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->legend->SetPos(0.5,0.01,'center','top');    //    top
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'b'    : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->legend->SetPos(0.5,0.99,'center','bottom');    //    bottom
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 default        : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->legend->SetPos(0.01,0.01,'right','top');    //    top-right
 | 
					
						
							|  |  |  |                     $this->graph->legend->SetColumns(1); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->legend->Hide(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderLegend()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderCartesianPlotArea($type='textlin') { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph = new Graph(self::$width,self::$height); | 
					
						
							|  |  |  |         $this->graph->SetScale($type); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderTitle(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //    Rotate for bar rather than column chart
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $reverse = ($rotation == 'bar') ? true : false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $xAxisLabel = $this->chart->getXAxisLabel(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (!is_null($xAxisLabel)) { | 
					
						
							|  |  |  |             $title = $this->_getCaption($xAxisLabel); | 
					
						
							|  |  |  |             if (!is_null($title)) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->graph->xaxis->SetTitle($title,'center'); | 
					
						
							|  |  |  |                 $this->graph->xaxis->title->SetMargin(35); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 if ($reverse) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->xaxis->title->SetAngle(90); | 
					
						
							|  |  |  |                     $this->graph->xaxis->title->SetMargin(90); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $yAxisLabel = $this->chart->getYAxisLabel(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if (!is_null($yAxisLabel)) { | 
					
						
							|  |  |  |             $title = $this->_getCaption($yAxisLabel); | 
					
						
							|  |  |  |             if (!is_null($title)) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->graph->yaxis->SetTitle($title,'center'); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 if ($reverse) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph->yaxis->title->SetAngle(0); | 
					
						
							|  |  |  |                     $this->graph->yaxis->title->SetMargin(-55); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderCartesianPlotArea()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPiePlotArea($doughnut = False) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph = new PieGraph(self::$width,self::$height); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderTitle(); | 
					
						
							|  |  |  |     }    //    function _renderPiePlotArea()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderRadarPlotArea() { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph = new RadarGraph(self::$width,self::$height); | 
					
						
							|  |  |  |         $this->graph->SetScale('lin'); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderTitle(); | 
					
						
							|  |  |  |     }    //    function _renderRadarPlotArea()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if ($labelCount > 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); | 
					
						
							|  |  |  |             $datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $labelCount); | 
					
						
							|  |  |  |             $this->graph->xaxis->SetTickLabels($datasetLabels); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlots = array(); | 
					
						
							|  |  |  |         if ($grouping == 'percentStacked') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //    Loop through each data series in turn
 | 
					
						
							|  |  |  |         for($i = 0; $i < $seriesCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							|  |  |  |             $marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if ($grouping == 'percentStacked') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //    Fill in any missing values in the $dataValues array
 | 
					
						
							|  |  |  |             $testCurrentIndex = 0; | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             foreach ($dataValues as $k => $dataValue) { | 
					
						
							|  |  |  |                 while ($k != $testCurrentIndex) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     $dataValues[$testCurrentIndex] = null; | 
					
						
							|  |  |  |                     ++$testCurrentIndex; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ++$testCurrentIndex; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $seriesPlot = new LinePlot($dataValues); | 
					
						
							|  |  |  |             if ($combination) { | 
					
						
							|  |  |  |                 $seriesPlot->SetBarCenter(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ($filled) { | 
					
						
							|  |  |  |                 $seriesPlot->SetFilled(true); | 
					
						
							|  |  |  |                 $seriesPlot->SetColor('black'); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour++]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 //    Set the appropriate plot marker
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->formatPointMarker($seriesPlot, $marker); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             $seriesPlot->SetLegend($dataLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $seriesPlots[] = $seriesPlot; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($grouping == 'standard') { | 
					
						
							|  |  |  |             $groupPlot = $seriesPlots; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $groupPlot = new AccLinePlot($seriesPlots); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Add($groupPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     }    //    function _renderPlotLine()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPlotBar($groupID, $dimensions = '2d') { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         //    Rotate for bar rather than column chart
 | 
					
						
							|  |  |  |         if (($groupID == 0) && ($rotation == 'bar')) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->Set90AndMargin(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if ($labelCount > 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); | 
					
						
							|  |  |  |             $datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             //    Rotate for bar rather than column chart
 | 
					
						
							|  |  |  |             if ($rotation == 'bar') { | 
					
						
							|  |  |  |                 $datasetLabels = array_reverse($datasetLabels); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->graph->yaxis->SetPos('max'); | 
					
						
							|  |  |  |                 $this->graph->yaxis->SetLabelAlign('center','top'); | 
					
						
							|  |  |  |                 $this->graph->yaxis->SetLabelSide(SIDE_RIGHT); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->xaxis->SetTickLabels($datasetLabels); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlots = array(); | 
					
						
							|  |  |  |         if ($grouping == 'percentStacked') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //    Loop through each data series in turn
 | 
					
						
							|  |  |  |         for($j = 0; $j < $seriesCount; ++$j) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if ($grouping == 'percentStacked') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //    Fill in any missing values in the $dataValues array
 | 
					
						
							|  |  |  |             $testCurrentIndex = 0; | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             foreach ($dataValues as $k => $dataValue) { | 
					
						
							|  |  |  |                 while ($k != $testCurrentIndex) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     $dataValues[$testCurrentIndex] = null; | 
					
						
							|  |  |  |                     ++$testCurrentIndex; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ++$testCurrentIndex; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //    Reverse the $dataValues order for bar rather than column chart
 | 
					
						
							|  |  |  |             if ($rotation == 'bar') { | 
					
						
							|  |  |  |                 $dataValues = array_reverse($dataValues); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $seriesPlot = new BarPlot($dataValues); | 
					
						
							|  |  |  |             $seriesPlot->SetColor('black'); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour++]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if ($dimensions == '3d') { | 
					
						
							|  |  |  |                 $seriesPlot->SetShadow(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             if (!$this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 $dataLabel = ''; | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             $seriesPlot->SetLegend($dataLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $seriesPlots[] = $seriesPlot; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         //    Reverse the plot order for bar rather than column chart
 | 
					
						
							|  |  |  |         if (($rotation == 'bar') && (!($grouping == 'percentStacked'))) { | 
					
						
							|  |  |  |             $seriesPlots = array_reverse($seriesPlots); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($grouping == 'clustered') { | 
					
						
							|  |  |  |             $groupPlot = new GroupBarPlot($seriesPlots); | 
					
						
							|  |  |  |         } elseif ($grouping == 'standard') { | 
					
						
							|  |  |  |             $groupPlot = new GroupBarPlot($seriesPlots); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $groupPlot = new AccBarPlot($seriesPlots); | 
					
						
							|  |  |  |             if ($dimensions == '3d') { | 
					
						
							|  |  |  |                 $groupPlot->SetShadow(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Add($groupPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     }    //    function _renderPlotBar()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |     private function _renderPlotScatter($groupID, $bubble) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); | 
					
						
							|  |  |  |         $scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlots = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //    Loop through each data series in turn
 | 
					
						
							|  |  |  |         for($i = 0; $i < $seriesCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); | 
					
						
							|  |  |  |             $dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             foreach ($dataValuesY as $k => $dataValueY) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 $dataValuesY[$k] = $k; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if ($scatterStyle == 'lineMarker') { | 
					
						
							|  |  |  |                 $seriesPlot->SetLinkPoints(); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $seriesPlot->link->SetColor(self::$colourSet[self::$_plotColour]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } elseif ($scatterStyle == 'smoothMarker') { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $spline = new Spline($dataValuesY, $dataValuesX); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$width / 20); | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $lplot = new LinePlot($splineDataX, $splineDataY); | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $lplot->SetColor(self::$colourSet[self::$_plotColour]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->graph->Add($lplot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ($bubble) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->formatPointMarker($seriesPlot,'dot'); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 $seriesPlot->mark->SetColor('black'); | 
					
						
							|  |  |  |                 $seriesPlot->mark->SetSize($bubbleSize); | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); | 
					
						
							|  |  |  |                 $this->formatPointMarker($seriesPlot, $marker); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             $seriesPlot->SetLegend($dataLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->Add($seriesPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderPlotScatter()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPlotRadar($groupID) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlots = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //    Loop through each data series in turn
 | 
					
						
							|  |  |  |         for($i = 0; $i < $seriesCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); | 
					
						
							|  |  |  |             $dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							|  |  |  |             $marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $dataValues = array(); | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             foreach ($dataValuesY as $k => $dataValueY) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 $dataValues[$k] = implode(' ',array_reverse($dataValueY)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $tmp = array_shift($dataValues); | 
					
						
							|  |  |  |             $dataValues[] = $tmp; | 
					
						
							|  |  |  |             $tmp = array_shift($dataValuesX); | 
					
						
							|  |  |  |             $dataValuesX[] = $tmp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->SetTitles(array_reverse($dataValues)); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $seriesPlot = new RadarPlot(array_reverse($dataValuesX)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); | 
					
						
							|  |  |  |             $seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if ($radarStyle == 'filled') { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->formatPointMarker($seriesPlot, $marker); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             $seriesPlot->SetLegend($dataLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $this->graph->Add($seriesPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderPlotRadar()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPlotContour($groupID) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlots = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $dataValues = array(); | 
					
						
							|  |  |  |         //    Loop through each data series in turn
 | 
					
						
							|  |  |  |         for($i = 0; $i < $seriesCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); | 
					
						
							|  |  |  |             $dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $dataValues[$i] = $dataValuesX; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $seriesPlot = new ContourPlot($dataValues); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Add($seriesPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     }    //    function _renderPlotContour()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderPlotStock($groupID) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							|  |  |  |         $plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $dataValues = array(); | 
					
						
							|  |  |  |         //    Loop through each data series in turn and build the plot arrays
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |         foreach ($plotOrder as $i => $v) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             foreach ($dataValuesX as $j => $dataValueX) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 $dataValues[$plotOrder[$i]][$j] = $dataValueX; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |         if (empty($dataValues)) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $dataValuesPlot = array(); | 
					
						
							| 
									
										
										
										
											2013-09-15 17:11:48 +00:00
										 |  |  |         // Flatten the plot arrays to a single dimensional array to work with jpgraph
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         for($j = 0; $j < count($dataValues[0]); $j++) { | 
					
						
							|  |  |  |             for($i = 0; $i < $seriesCount; $i++) { | 
					
						
							|  |  |  |                 $dataValuesPlot[] = $dataValues[$i][$j]; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-15 17:11:48 +00:00
										 |  |  |         // Set the x-axis labels
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         if ($labelCount > 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); | 
					
						
							|  |  |  |             $datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $labelCount); | 
					
						
							|  |  |  |             $this->graph->xaxis->SetTickLabels($datasetLabels); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-09-15 11:44:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $seriesPlot = new StockPlot($dataValuesPlot); | 
					
						
							|  |  |  |         $seriesPlot->SetWidth(20); | 
					
						
							| 
									
										
										
										
											2013-09-15 17:11:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Add($seriesPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     }    //    function _renderPlotStock()
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     private function _renderAreaChart($groupCount, $dimensions = '2d') { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $this->_renderCartesianPlotArea(); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $this->_renderPlotLine($i,True,False, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderAreaChart()
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     private function _renderLineChart($groupCount, $dimensions = '2d') { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $this->_renderCartesianPlotArea(); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $this->_renderPlotLine($i,False,False, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderLineChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderBarChart($groupCount, $dimensions = '2d') { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderCartesianPlotArea(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |             $this->_renderPlotBar($i, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderBarChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderScatterChart($groupCount) { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $this->_renderCartesianPlotArea('linlin'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							|  |  |  |             $this->_renderPlotScatter($i,false); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderScatterChart()
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     private function _renderBubbleChart($groupCount) { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $this->_renderCartesianPlotArea('linlin'); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							|  |  |  |             $this->_renderPlotScatter($i,true); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderBubbleChart()
 | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |     private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php'); | 
					
						
							|  |  |  |         if ($dimensions == '3d') { | 
					
						
							|  |  |  |             require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php'); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $this->_renderPiePlotArea($doughnut); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         $iLimit = ($multiplePlots) ? $groupCount : 1; | 
					
						
							|  |  |  |         for($groupID = 0; $groupID < $iLimit; ++$groupID) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); | 
					
						
							|  |  |  |             $exploded = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             if ($groupID == 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 if ($labelCount > 0) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); | 
					
						
							|  |  |  |                     $datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $labelCount); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             $seriesPlots = array(); | 
					
						
							|  |  |  |             //    For pie charts, we only display the first series: doughnut charts generally display all series
 | 
					
						
							|  |  |  |             $jLimit = ($multiplePlots) ? $seriesCount : 1; | 
					
						
							|  |  |  |             //    Loop through each data series in turn
 | 
					
						
							|  |  |  |             for($j = 0; $j < $jLimit; ++$j) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); | 
					
						
							| 
									
										
										
										
											2012-02-08 21:17:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 //    Fill in any missing values in the $dataValues array
 | 
					
						
							|  |  |  |                 $testCurrentIndex = 0; | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 foreach ($dataValues as $k => $dataValue) { | 
					
						
							|  |  |  |                     while ($k != $testCurrentIndex) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                         $dataValues[$testCurrentIndex] = null; | 
					
						
							|  |  |  |                         ++$testCurrentIndex; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     ++$testCurrentIndex; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if ($dimensions == '3d') { | 
					
						
							|  |  |  |                     $seriesPlot = new PiePlot3D($dataValues); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     if ($doughnut) { | 
					
						
							|  |  |  |                         $seriesPlot = new PiePlotC($dataValues); | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $seriesPlot = new PiePlot($dataValues); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if ($multiplePlots) { | 
					
						
							|  |  |  |                     $seriesPlot->SetSize(($jLimit-$j) / ($jLimit * 4)); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if ($doughnut) { | 
					
						
							|  |  |  |                     $seriesPlot->SetMidColor('white'); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 if (count($datasetLabels) > 0) | 
					
						
							|  |  |  |                     $seriesPlot->SetLabels(array_fill(0,count($datasetLabels),'')); | 
					
						
							|  |  |  |                 if ($dimensions != '3d') { | 
					
						
							|  |  |  |                     $seriesPlot->SetGuideLines(false); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if ($j == 0) { | 
					
						
							|  |  |  |                     if ($exploded) { | 
					
						
							|  |  |  |                         $seriesPlot->ExplodeAll(); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     $seriesPlot->SetLegends($datasetLabels); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $this->graph->Add($seriesPlot); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderPieChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderRadarChart($groupCount) { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderRadarPlotArea(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($groupID = 0; $groupID < $groupCount; ++$groupID) { | 
					
						
							|  |  |  |             $this->_renderPlotRadar($groupID); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderRadarChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function _renderStockChart($groupCount) { | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderCartesianPlotArea('intint'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($groupID = 0; $groupID < $groupCount; ++$groupID) { | 
					
						
							|  |  |  |             $this->_renderPlotStock($groupID); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderStockChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |     private function _renderContourChart($groupCount, $dimensions) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderCartesianPlotArea('intint'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							|  |  |  |             $this->_renderPlotContour($i); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }    //    function _renderContourChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |     private function _renderCombinationChart($groupCount, $dimensions, $outputDestination) { | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); | 
					
						
							|  |  |  |         require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderCartesianPlotArea(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							|  |  |  |             $dimensions = null; | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $chartType = $this->chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             switch ($chartType) { | 
					
						
							|  |  |  |                 case 'area3DChart' : | 
					
						
							|  |  |  |                     $dimensions = '3d'; | 
					
						
							|  |  |  |                 case 'areaChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $this->_renderPlotLine($i,True,True, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'bar3DChart' : | 
					
						
							|  |  |  |                     $dimensions = '3d'; | 
					
						
							|  |  |  |                 case 'barChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $this->_renderPlotBar($i, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'line3DChart' : | 
					
						
							|  |  |  |                     $dimensions = '3d'; | 
					
						
							|  |  |  |                 case 'lineChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                     $this->_renderPlotLine($i,False,True, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'scatterChart' : | 
					
						
							|  |  |  |                     $this->_renderPlotScatter($i,false); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'bubbleChart' : | 
					
						
							|  |  |  |                     $this->_renderPlotScatter($i,true); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 default    : | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                     $this->graph = null; | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                     return false; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->_renderLegend(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Stroke($outputDestination); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     }    //    function _renderCombinationChart()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function render($outputDestination) { | 
					
						
							| 
									
										
										
										
											2012-10-07 09:30:15 +00:00
										 |  |  |         self::$_plotColour = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $groupCount = $this->chart->getPlotArea()->getPlotGroupCount(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $dimensions = null; | 
					
						
							|  |  |  |         if ($groupCount == 1) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |             $chartType = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             $chartTypes = array(); | 
					
						
							|  |  |  |             for($i = 0; $i < $groupCount; ++$i) { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |                 $chartTypes[] = $this->chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             $chartTypes = array_unique($chartTypes); | 
					
						
							|  |  |  |             if (count($chartTypes) == 1) { | 
					
						
							|  |  |  |                 $chartType = array_pop($chartTypes); | 
					
						
							|  |  |  |             } elseif (count($chartTypes) == 0) { | 
					
						
							|  |  |  |                 echo 'Chart is not yet implemented<br />'; | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 return $this->_renderCombinationChart($groupCount, $dimensions, $outputDestination); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         switch ($chartType) { | 
					
						
							|  |  |  |             case 'area3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'areaChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderAreaChart($groupCount, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'bar3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'barChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderBarChart($groupCount, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'line3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'lineChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderLineChart($groupCount, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'pie3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'pieChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderPieChart($groupCount, $dimensions,False,False); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'doughnut3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'doughnutChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderPieChart($groupCount, $dimensions,True,True); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'scatterChart' : | 
					
						
							|  |  |  |                 $this->_renderScatterChart($groupCount); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'bubbleChart' : | 
					
						
							|  |  |  |                 $this->_renderBubbleChart($groupCount); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'radarChart' : | 
					
						
							|  |  |  |                 $this->_renderRadarChart($groupCount); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'surface3DChart' : | 
					
						
							|  |  |  |                 $dimensions = '3d'; | 
					
						
							|  |  |  |             case 'surfaceChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderContourChart($groupCount, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case 'stockChart' : | 
					
						
							| 
									
										
										
										
											2015-05-13 10:27:01 +00:00
										 |  |  |                 $this->_renderStockChart($groupCount, $dimensions); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default    : | 
					
						
							|  |  |  |                 echo $chartType.' is not yet implemented<br />'; | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $this->_renderLegend(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph->Stroke($outputDestination); | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-12 07:00:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Create a new PHPExcel_Chart_Renderer_jpgraph | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __construct(PHPExcel_Chart $chart) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-05-15 08:11:18 +00:00
										 |  |  |         $this->graph    = null; | 
					
						
							|  |  |  |         $this->chart    = $chart; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |