Initial addition of chart classes, though not yet including the reader/writer code for loading the classes
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@86197 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
0285c3e428
commit
73f013c68f
|
@ -0,0 +1,474 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart
|
||||
{
|
||||
/**
|
||||
* Chart Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name = '';
|
||||
|
||||
/**
|
||||
* Worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet = null;
|
||||
|
||||
/**
|
||||
* Chart Title
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_title = null;
|
||||
|
||||
/**
|
||||
* Chart Legend
|
||||
*
|
||||
* @var PHPExcel_Chart_Legend
|
||||
*/
|
||||
private $_legend = null;
|
||||
|
||||
/**
|
||||
* X-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_xAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Y-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_yAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Chart Plot Area
|
||||
*
|
||||
* @var PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
private $_plotArea = null;
|
||||
|
||||
/**
|
||||
* Plot Visible Only
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotVisibleOnly = true;
|
||||
|
||||
/**
|
||||
* Display Blanks as
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_displayBlanksAs = '0';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_topLeftCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftXOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftYOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_bottomRightCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightXOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightYOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart
|
||||
*/
|
||||
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null)
|
||||
{
|
||||
$this->_name = $name;
|
||||
$this->_title = $title;
|
||||
$this->_legend = $legend;
|
||||
$this->_xAxisLabel = $xAxisLabel;
|
||||
$this->_yAxisLabel = $yAxisLabel;
|
||||
$this->_plotArea = $plotArea;
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pValue
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
|
||||
$this->_worksheet = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Legend
|
||||
*
|
||||
* @return PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function getLegend() {
|
||||
return $this->_legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getXAxisLabel() {
|
||||
return $this->_xAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getYAxisLabel() {
|
||||
return $this->_yAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Area
|
||||
*
|
||||
* @return PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function getPlotArea() {
|
||||
return $this->_plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Visible Only
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPlotVisibleOnly() {
|
||||
return $this->_plotVisibleOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Visible Only
|
||||
*
|
||||
* @param boolean $plotVisibleOnly
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setPlotVisibleOnly($plotVisibleOnly = true) {
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Blanks as
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayBlanksAs() {
|
||||
return $this->_displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Blanks as
|
||||
*
|
||||
* @param string $displayBlanksAs
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setDisplayBlanksAs($displayBlanksAs = '0') {
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Top Left position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top left position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getTopLeftPosition() {
|
||||
return array( 'cell' => $this->_topLeftCellRef,
|
||||
'xOffset' => $this->_topLeftXOffset,
|
||||
'yOffset' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the top left of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeftCell() {
|
||||
return $this->_topLeftCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Top Left cell position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftCell($cell) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTopLeftOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftOffset() {
|
||||
return array( 'X' => $this->_topLeftXOffset,
|
||||
'Y' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setTopLeftXOffset($xOffset) {
|
||||
$this->_topLeftXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftXOffset() {
|
||||
return $this->_topLeftXOffset;
|
||||
}
|
||||
|
||||
public function setTopLeftYOffset($yOffset) {
|
||||
$this->_topLeftYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftYOffset() {
|
||||
return $this->_topLeftYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bottom Right position of the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom right position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getBottomRightPosition() {
|
||||
return array( 'cell' => $this->_bottomRightCellRef,
|
||||
'xOffset' => $this->_bottomRightXOffset,
|
||||
'yOffset' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightCell($cell) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the bottom right of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRightCell() {
|
||||
return $this->_bottomRightCellRef;
|
||||
}
|
||||
|
||||
public function setBottomRightOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightOffset() {
|
||||
return array( 'X' => $this->_bottomRightXOffset,
|
||||
'Y' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightXOffset($xOffset) {
|
||||
$this->_bottomRightXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightXOffset() {
|
||||
return $this->_bottomRightXOffset;
|
||||
}
|
||||
|
||||
public function setBottomRightYOffset($yOffset) {
|
||||
$this->_bottomRightYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightYOffset() {
|
||||
return $this->_bottomRightYOffset;
|
||||
}
|
||||
|
||||
|
||||
public function refresh() {
|
||||
}
|
||||
|
||||
public function render($outputDestination = null) {
|
||||
$libraryName = PHPExcel_Settings::getChartRendererName();
|
||||
if (is_null($libraryName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$libraryPath = PHPExcel_Settings::getChartRendererPath();
|
||||
$includePath = str_replace('\\','/',get_include_path());
|
||||
$rendererPath = str_replace('\\','/',$libraryPath);
|
||||
if (strpos($rendererPath,$includePath) === false) {
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
|
||||
}
|
||||
|
||||
$rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
|
||||
$renderer = new $rendererName($this);
|
||||
|
||||
if ($outputDestination == 'php://output') {
|
||||
$outputDestination = null;
|
||||
}
|
||||
return $renderer->render($outputDestination);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,317 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeries
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeries
|
||||
{
|
||||
|
||||
const TYPE_BARCHART = 'barChart';
|
||||
const TYPE_BARCHART_3D = 'bar3DChart';
|
||||
const TYPE_LINECHART = 'lineChart';
|
||||
const TYPE_LINECHART_3D = 'line3DChart';
|
||||
const TYPE_AREACHART = 'areaChart';
|
||||
const TYPE_AREACHART_3D = 'area3DChart';
|
||||
const TYPE_PIECHART = 'pieChart';
|
||||
const TYPE_PIECHART_3D = 'pie3DChart';
|
||||
const TYPE_DOUGHTNUTCHART = 'doughnutChart';
|
||||
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
|
||||
const TYPE_SCATTERCHART = 'scatterChart';
|
||||
const TYPE_SURFACECHART = 'surfaceChart';
|
||||
const TYPE_SURFACECHART_3D = 'surface3DChart';
|
||||
const TYPE_RADARCHART = 'radarChart';
|
||||
const TYPE_BUBBLECHART = 'bubbleChart';
|
||||
const TYPE_STOCKCHART = 'stockChart';
|
||||
|
||||
const GROUPING_CLUSTERED = 'clustered';
|
||||
const GROUPING_STACKED = 'stacked';
|
||||
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
||||
const GROUPING_STANDARD = 'standard';
|
||||
|
||||
const DIRECTION_BAR = 'bar';
|
||||
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
||||
const DIRECTION_COL = 'col';
|
||||
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
||||
const DIRECTION_VERTICAL = self::DIRECTION_COL;
|
||||
|
||||
const STYLE_LINEMARKER = 'lineMarker';
|
||||
const STYLE_SMOOTHMARKER = 'smoothMarker';
|
||||
const STYLE_MARKER = 'marker';
|
||||
const STYLE_FILLED = 'filled';
|
||||
|
||||
|
||||
/**
|
||||
* Series Plot Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotType = null;
|
||||
|
||||
/**
|
||||
* Plot Grouping Type
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotGrouping = null;
|
||||
|
||||
/**
|
||||
* Plot Direction
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotDirection = null;
|
||||
|
||||
/**
|
||||
* Plot Style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotStyle = null;
|
||||
|
||||
/**
|
||||
* Order of plots in Series
|
||||
*
|
||||
* @var array of integer
|
||||
*/
|
||||
private $_plotOrder = array();
|
||||
|
||||
/**
|
||||
* Plot Label
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotLabel = array();
|
||||
|
||||
/**
|
||||
* Plot Category
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotCategory = array();
|
||||
|
||||
/**
|
||||
* Smooth Line
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_smoothLine = null;
|
||||
|
||||
/**
|
||||
* Plot Values
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotValues = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
|
||||
{
|
||||
$this->_plotType = $plotType;
|
||||
$this->_plotGrouping = $plotGrouping;
|
||||
$this->_plotOrder = $plotOrder;
|
||||
$keys = array_keys($plotValues);
|
||||
$this->_plotValues = $plotValues;
|
||||
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
||||
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
$this->_plotLabel = $plotLabel;
|
||||
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
||||
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
$this->_plotCategory = $plotCategory;
|
||||
$this->_smoothLine = $smoothLine;
|
||||
$this->_plotStyle = $plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotType() {
|
||||
return $this->_plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Type
|
||||
*
|
||||
* @param string $plotType
|
||||
*/
|
||||
public function setPlotType($plotType = '') {
|
||||
$this->_plotType = $plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Grouping Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotGrouping() {
|
||||
return $this->_plotGrouping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Grouping Type
|
||||
*
|
||||
* @param string $groupingType
|
||||
*/
|
||||
public function setPlotGrouping($groupingType = null) {
|
||||
$this->_plotGrouping = $groupingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Direction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotDirection() {
|
||||
return $this->_plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Direction
|
||||
*
|
||||
* @param string $plotDirection
|
||||
*/
|
||||
public function setPlotDirection($plotDirection = null) {
|
||||
$this->_plotDirection = $plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotOrder() {
|
||||
return $this->_plotOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Labels
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabels() {
|
||||
return $this->_plotLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Label by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabelByIndex($index) {
|
||||
$keys = array_keys($this->_plotLabel);
|
||||
if (isset($keys[$index])) {
|
||||
$index = $keys[$index];
|
||||
return $this->_plotLabel[$index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Categories
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategories() {
|
||||
return $this->_plotCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Category by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategoryByIndex($index) {
|
||||
$keys = array_keys($this->_plotCategory);
|
||||
if (isset($keys[$index])) {
|
||||
$index = $keys[$index];
|
||||
return $this->_plotCategory[$index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotStyle() {
|
||||
return $this->_plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Style
|
||||
*
|
||||
* @param string $plotStyle
|
||||
*/
|
||||
public function setPlotStyle($plotStyle = null) {
|
||||
$this->_plotStyle = $plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValues() {
|
||||
return $this->_plotValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValuesByIndex($index) {
|
||||
$keys = array_keys($this->_plotValues);
|
||||
if (isset($keys[$index])) {
|
||||
$index = $keys[$index];
|
||||
return $this->_plotValues[$index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
return count($this->_plotValues);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeriesValues
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeriesValues
|
||||
{
|
||||
|
||||
/**
|
||||
* Series Data Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataType = null;
|
||||
|
||||
/**
|
||||
* Series Data Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataSource = null;
|
||||
|
||||
/**
|
||||
* Format Code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formatCode = null;
|
||||
|
||||
/**
|
||||
* Series Point Marker
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marker = null;
|
||||
|
||||
/**
|
||||
* Point Count (The number of datapoints in the dataseries)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_pointCount = 0;
|
||||
|
||||
/**
|
||||
* Data Values
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $_dataValues = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_DataSeriesValues object
|
||||
*/
|
||||
public function __construct($dataType = null, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
|
||||
{
|
||||
$this->_dataType = $dataType;
|
||||
$this->_dataSource = $dataSource;
|
||||
$this->_formatCode = $formatCode;
|
||||
$this->_pointCount = $pointCount;
|
||||
$this->_dataValues = $dataValues;
|
||||
$this->_marker = $marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataType() {
|
||||
return $this->_dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Type
|
||||
*
|
||||
* @param string $dataType
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataType($dataType = 'Number') {
|
||||
$this->_dataType = $dataType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Source (formula)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataSource() {
|
||||
return $this->_dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Source (formula)
|
||||
*
|
||||
* @param string $dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataSource($dataSource = null, $refreshDataValues = true) {
|
||||
$this->_dataSource = $dataSource;
|
||||
|
||||
if ($refreshDataValues) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Point Marker
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPointMarker() {
|
||||
return $this->_marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Point Marker
|
||||
*
|
||||
* @param string $marker
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setPointMarker($marker = null) {
|
||||
$this->_marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode() {
|
||||
return $this->_formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Format Code
|
||||
*
|
||||
* @param string $formatCode
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setFormatCode($formatCode = null) {
|
||||
$this->_formatCode = $formatCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Point Count
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPointCount() {
|
||||
return $this->_pointCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMultiLevelSeries() {
|
||||
if (count($this->_dataValues) > 0) {
|
||||
return is_array($this->_dataValues[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function multiLevelCount() {
|
||||
$levelCount = 0;
|
||||
foreach($this->_dataValues as $dataValueSet) {
|
||||
$levelCount = max($levelCount,count($dataValueSet));
|
||||
}
|
||||
return $levelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Values
|
||||
*
|
||||
* @return array of mixed
|
||||
*/
|
||||
public function getDataValues() {
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first Series Data value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDataValue() {
|
||||
$count = count($this->_dataValues);
|
||||
if ($count == 0) {
|
||||
return null;
|
||||
} elseif ($count == 1) {
|
||||
return $this->_dataValues[0];
|
||||
}
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Values
|
||||
*
|
||||
* @param array $dataValues
|
||||
* @param boolean $refreshDataSource
|
||||
* TRUE - refresh the value of _dataSource based on the values of $dataValues
|
||||
* FALSE - don't change the value of _dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataValues($dataValues = array(), $refreshDataSource = true) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
|
||||
$this->_pointCount = count($dataValues);
|
||||
|
||||
if ($refreshDataSource) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Layout
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Layout
|
||||
{
|
||||
/**
|
||||
* layoutTarget
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_layoutTarget = null;
|
||||
|
||||
/**
|
||||
* X Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_xMode = null;
|
||||
|
||||
/**
|
||||
* Y Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_yMode = null;
|
||||
|
||||
/**
|
||||
* X-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_xPos = null;
|
||||
|
||||
/**
|
||||
* Y-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_yPos = null;
|
||||
|
||||
/**
|
||||
* width
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_width = null;
|
||||
|
||||
/**
|
||||
* height
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_height = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function __construct($layout=array())
|
||||
{
|
||||
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
|
||||
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
|
||||
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
|
||||
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
|
||||
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
|
||||
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
|
||||
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout Target
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLayoutTarget() {
|
||||
return $this->_layoutTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Layout Target
|
||||
*
|
||||
* @param Layout Target $value
|
||||
*/
|
||||
public function setLayoutTarget($value) {
|
||||
$this->_layoutTarget = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXMode() {
|
||||
return $this->_xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Mode
|
||||
*
|
||||
* @param X-Mode $value
|
||||
*/
|
||||
public function setXMode($value) {
|
||||
$this->_xMode = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getYMode() {
|
||||
return $this->_xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Mode
|
||||
*
|
||||
* @param Y-Mode $value
|
||||
*/
|
||||
public function setYMode($value) {
|
||||
$this->_xMode = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getXPosition() {
|
||||
return $this->_xPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Position
|
||||
*
|
||||
* @param X-Position $value
|
||||
*/
|
||||
public function setXPosition($value) {
|
||||
$this->_xPos = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getYPosition() {
|
||||
return $this->_yPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Position
|
||||
*
|
||||
* @param Y-Position $value
|
||||
*/
|
||||
public function setYPosition($value) {
|
||||
$this->_yPos = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param Width $value
|
||||
*/
|
||||
public function setWidth($value) {
|
||||
$this->_width = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param Height $value
|
||||
*/
|
||||
public function setHeight($value) {
|
||||
$this->_height = $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Legend
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Legend
|
||||
{
|
||||
/** Legend positions */
|
||||
const xlLegendPositionBottom = -4107; // Below the chart.
|
||||
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
|
||||
const xlLegendPositionCustom = -4161; // A custom position.
|
||||
const xlLegendPositionLeft = -4131; // Left of the chart.
|
||||
const xlLegendPositionRight = -4152; // Right of the chart.
|
||||
const xlLegendPositionTop = -4160; // Above the chart.
|
||||
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
private static $_positionXref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
|
||||
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
|
||||
self::xlLegendPositionCustom => '??',
|
||||
self::xlLegendPositionLeft => self::POSITION_LEFT,
|
||||
self::xlLegendPositionRight => self::POSITION_RIGHT,
|
||||
self::xlLegendPositionTop => self::POSITION_TOP
|
||||
);
|
||||
|
||||
/**
|
||||
* Legend position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* Allow overlay of other elements?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_overlay = true;
|
||||
|
||||
/**
|
||||
* Legend Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function __construct($position = null, PHPExcel_Chart_Layout $layout = null, $overlay= false)
|
||||
{
|
||||
$this->_position = $position;
|
||||
$this->_layout = $layout;
|
||||
$this->_overlay = $overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an excel string value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position using an excel string value
|
||||
*
|
||||
* @param string $position
|
||||
*/
|
||||
public function setPosition($position = self::POSITION_RIGHT) {
|
||||
if (!in_array($position,self::$positionXref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = $position;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an Excel internal numeric value
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getPositionXL() {
|
||||
return array_search($this->_position,self::$positionXref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legend position using an Excel internal numeric value
|
||||
*
|
||||
* @param number $positionXL
|
||||
*/
|
||||
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
|
||||
if (!array_key_exists($positionXL,self::$positionXref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = self::$positionXref[$positionXL];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allow overlay of other elements?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOverlay() {
|
||||
return $this->_overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allow overlay of other elements?
|
||||
*
|
||||
* @param boolean $value
|
||||
*/
|
||||
public function setOverlay($value=false) {
|
||||
$this->_overlay = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_PlotArea
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_PlotArea
|
||||
{
|
||||
/**
|
||||
* PlotArea Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Plot Series
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
private $_plotSeries = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
|
||||
{
|
||||
$this->_layout = $layout;
|
||||
$this->_plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Groups
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupCount() {
|
||||
return count($this->_plotSeries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
$seriesCount = 0;
|
||||
foreach($this->_plotSeries as $plot) {
|
||||
$seriesCount += $plot->getPlotSeriesCount();
|
||||
}
|
||||
return $seriesCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroup() {
|
||||
return $this->_plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupByIndex($index) {
|
||||
return $this->_plotSeries[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Series
|
||||
*
|
||||
* @param array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotSeries($plotSeries = array()) {
|
||||
$this->_plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,831 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php');
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Renderer_jpgraph
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart_Renderer
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Renderer_jpgraph
|
||||
{
|
||||
private static $_width = 640;
|
||||
|
||||
private static $_height = 480;
|
||||
|
||||
private static $_colourSet = array( 'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1',
|
||||
'darkmagenta', 'coral', 'dodgerblue3', 'eggplant',
|
||||
'mediumblue', 'magenta', 'sandybrown', 'cyan',
|
||||
'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen',
|
||||
'goldenrod2'
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
private $_chart = null;
|
||||
|
||||
private $_graph = null;
|
||||
|
||||
private static $_plotColour = 0;
|
||||
|
||||
private static $_plotMark = 0;
|
||||
|
||||
|
||||
private function _formatPointMarker($seriesPlot,$markerID) {
|
||||
$plotMarkKeys = array_keys(self::$_markSet);
|
||||
if (is_null($markerID)) {
|
||||
// Use default plot marker (next marker in the series)
|
||||
self::$_plotMark %= count(self::$_markSet);
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
|
||||
} elseif ($markerID !== 'none') {
|
||||
// Use specified plot marker (if it exists)
|
||||
if (isset(self::$_markSet[$markerID])) {
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$markerID]);
|
||||
} else {
|
||||
// If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
|
||||
self::$_plotMark %= count(self::$_markSet);
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
|
||||
}
|
||||
} else {
|
||||
// Hide plot marker
|
||||
$seriesPlot->mark->Hide();
|
||||
}
|
||||
$seriesPlot->mark->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
$seriesPlot->mark->SetFillColor(self::$_colourSet[self::$_plotColour]);
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
|
||||
return $seriesPlot;
|
||||
} // function _formatPointMarker()
|
||||
|
||||
|
||||
private function _formatDataSetLabels($groupID,$datasetLabels,$rotation = '') {
|
||||
$datasetLabelFormatCode = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
|
||||
if (!is_null($datasetLabelFormatCode)) {
|
||||
// Retrieve any label formatting code
|
||||
$datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
|
||||
}
|
||||
|
||||
$testCurrentIndex = 0;
|
||||
foreach($datasetLabels as $i => $datasetLabel) {
|
||||
// Fill in any missing values in the $datasetLabels array
|
||||
while ($i != $testCurrentIndex) {
|
||||
$datasetLabels[$testCurrentIndex] = '';
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
if (is_array($datasetLabel)) {
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabel = array_reverse($datasetLabel);
|
||||
$datasetLabels[$i] = implode(" ",$datasetLabel);
|
||||
} else {
|
||||
$datasetLabels[$i] = implode("\n",$datasetLabel);
|
||||
}
|
||||
} else {
|
||||
// Format labels according to any formatting code
|
||||
if (!is_null($datasetLabelFormatCode)) {
|
||||
$datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode);
|
||||
}
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
return $datasetLabels;
|
||||
} // function _formatDataSetLabels()
|
||||
|
||||
|
||||
private function _percentageSumCalculation($groupID,$seriesCount) {
|
||||
// Adjust our values to a percentage value across all series in the group
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
if ($i == 0) {
|
||||
$sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
} else {
|
||||
$nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
foreach($nextValues as $k => $value) {
|
||||
if (isset($sumValues[$k])) {
|
||||
$sumValues[$k] += $value;
|
||||
} else {
|
||||
$sumValues[$k] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sumValues;
|
||||
} // function _percentageSumCalculation()
|
||||
|
||||
|
||||
private function _percentageAdjustValues($dataValues,$sumValues) {
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
$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
|
||||
$caption = implode('',$caption);
|
||||
}
|
||||
}
|
||||
return $caption;
|
||||
} // function _getCaption()
|
||||
|
||||
|
||||
private function _renderTitle() {
|
||||
$title = $this->_getCaption($this->_chart->getTitle());
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->title->Set($title);
|
||||
}
|
||||
} // function _renderTitle()
|
||||
|
||||
|
||||
private function _renderLegend() {
|
||||
$legend = $this->_chart->getLegend();
|
||||
if (!is_null($legend)) {
|
||||
$legendPosition = $legend->getPosition();
|
||||
$legendOverlay = $legend->getOverlay();
|
||||
switch ($legendPosition) {
|
||||
case 'r' :
|
||||
$this->_graph->legend->SetPos(0.01,0.5,'right','center'); // right
|
||||
break;
|
||||
case 'l' :
|
||||
$this->_graph->legend->SetPos(0.01,0.5,'left','center'); // left
|
||||
break;
|
||||
case 't' :
|
||||
$this->_graph->legend->SetPos(0.5,0.01,'center','top'); // top
|
||||
break;
|
||||
case 'b' :
|
||||
$this->_graph->legend->SetPos(0.5,0.99,'center','bottom'); // bottom
|
||||
break;
|
||||
default :
|
||||
$this->_graph->legend->SetPos(0.01,0.01,'right','top'); // top-right
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // function _renderLegend()
|
||||
|
||||
|
||||
private function _renderCartesianPlotArea($type='textlin') {
|
||||
$this->_graph = new Graph(self::$_width,self::$_height);
|
||||
$this->_graph->SetScale($type);
|
||||
|
||||
$this->_renderTitle();
|
||||
|
||||
// Rotate for bar rather than column chart
|
||||
$rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
|
||||
$reverse = ($rotation == 'bar') ? true : false;
|
||||
|
||||
$xAxisLabel = $this->_chart->getXAxisLabel();
|
||||
if (!is_null($xAxisLabel)) {
|
||||
$title = $this->_getCaption($xAxisLabel);
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->xaxis->SetTitle($title,'center');
|
||||
$this->_graph->xaxis->title->SetMargin(35);
|
||||
if ($reverse) {
|
||||
$this->_graph->xaxis->title->SetAngle(90);
|
||||
$this->_graph->xaxis->title->SetMargin(90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$yAxisLabel = $this->_chart->getYAxisLabel();
|
||||
if (!is_null($yAxisLabel)) {
|
||||
$title = $this->_getCaption($yAxisLabel);
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->yaxis->SetTitle($title,'center');
|
||||
if ($reverse) {
|
||||
$this->_graph->yaxis->title->SetAngle(0);
|
||||
$this->_graph->yaxis->title->SetMargin(-55);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // function _renderCartesianPlotArea()
|
||||
|
||||
|
||||
private function _renderPiePlotArea($doughnut = False) {
|
||||
$this->_graph = new PieGraph(self::$_width,self::$_height);
|
||||
|
||||
$this->_renderTitle();
|
||||
} // function _renderPiePlotArea()
|
||||
|
||||
|
||||
private function _renderRadarPlotArea() {
|
||||
$this->_graph = new RadarGraph(self::$_width,self::$_height);
|
||||
$this->_graph->SetScale('lin');
|
||||
|
||||
$this->_renderTitle();
|
||||
} // function _renderRadarPlotArea()
|
||||
|
||||
|
||||
private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
if (count($datasetLabels) > 0) {
|
||||
$datasetLabels = $this->_formatDataSetLabels($groupID,$datasetLabels);
|
||||
$this->_graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
$seriesPlot = new LinePlot($dataValues);
|
||||
if ($combination) {
|
||||
$seriesPlot->SetBarCenter();
|
||||
}
|
||||
|
||||
if ($filled) {
|
||||
$seriesPlot->SetFilled(true);
|
||||
$seriesPlot->SetColor('black');
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
|
||||
} else {
|
||||
// Set the appropriate plot marker
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
}
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$seriesPlots[] = $seriesPlot;
|
||||
}
|
||||
|
||||
if ($grouping == 'standard') {
|
||||
$groupPlot = $seriesPlots;
|
||||
} else {
|
||||
$groupPlot = new AccLinePlot($seriesPlots);
|
||||
}
|
||||
$this->_graph->Add($groupPlot);
|
||||
} // function _renderPlotLine()
|
||||
|
||||
|
||||
private function _renderPlotBar($groupID, $dimensions = '2d') {
|
||||
$rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
||||
// Rotate for bar rather than column chart
|
||||
if (($groupID == 0) && ($rotation == 'bar')) {
|
||||
$this->_graph->Set90AndMargin();
|
||||
}
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
if (count($datasetLabels) > 0) {
|
||||
$datasetLabels = $this->_formatDataSetLabels($groupID,$datasetLabels,$rotation);
|
||||
// Rotate for bar rather than column chart
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels = array_reverse($datasetLabels);
|
||||
$this->_graph->yaxis->SetPos('max');
|
||||
$this->_graph->yaxis->SetLabelAlign('center','top');
|
||||
$this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
|
||||
}
|
||||
$this->_graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($j = 0; $j < $seriesCount; ++$j) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$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');
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
|
||||
if ($dimensions == '3d') {
|
||||
$seriesPlot->SetShadow();
|
||||
}
|
||||
if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
|
||||
$dataLabel = '';
|
||||
} else {
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
|
||||
}
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_graph->Add($groupPlot);
|
||||
} // function _renderPlotBar()
|
||||
|
||||
|
||||
private function _renderPlotScatter($groupID,$bubble) {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
$scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
foreach($dataValuesY as $k => $dataValueY) {
|
||||
$dataValuesY[$k] = $k;
|
||||
}
|
||||
|
||||
$seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY);
|
||||
if ($scatterStyle == 'lineMarker') {
|
||||
$seriesPlot->SetLinkPoints();
|
||||
$seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
} elseif ($scatterStyle == 'smoothMarker') {
|
||||
$spline = new Spline($dataValuesY,$dataValuesX);
|
||||
list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
|
||||
$lplot = new LinePlot($splineDataX,$splineDataY);
|
||||
$lplot->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
|
||||
$this->_graph->Add($lplot);
|
||||
}
|
||||
|
||||
if ($bubble) {
|
||||
$this->_formatPointMarker($seriesPlot,'dot');
|
||||
$seriesPlot->mark->SetColor('black');
|
||||
$seriesPlot->mark->SetSize($bubbleSize);
|
||||
} else {
|
||||
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
}
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
} // function _renderPlotScatter()
|
||||
|
||||
|
||||
private function _renderPlotRadar($groupID) {
|
||||
$radarStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$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();
|
||||
|
||||
$dataValues = array();
|
||||
foreach($dataValuesY as $k => $dataValueY) {
|
||||
$dataValues[$k] = implode(' ',array_reverse($dataValueY));
|
||||
}
|
||||
$tmp = array_shift($dataValues);
|
||||
$dataValues[] = $tmp;
|
||||
$tmp = array_shift($dataValuesX);
|
||||
$dataValuesX[] = $tmp;
|
||||
|
||||
$this->_graph->SetTitles(array_reverse($dataValues));
|
||||
|
||||
$seriesPlot = new RadarPlot(array_reverse($dataValuesX));
|
||||
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
if ($radarStyle == 'filled') {
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]);
|
||||
}
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
} // function _renderPlotRadar()
|
||||
|
||||
|
||||
private function _renderPlotContour($groupID) {
|
||||
$contourStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
$dataValues = array();
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
$dataValues[$i] = $dataValuesX;
|
||||
}
|
||||
$seriesPlot = new ContourPlot($dataValues);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
} // function _renderPlotContour()
|
||||
|
||||
|
||||
private function _renderPlotStock($groupID) {
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
||||
$seriesPlots = array();
|
||||
|
||||
$dataValues = array();
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
foreach($dataValuesX as $j => $dataValueX)
|
||||
$dataValues[$j][$plotOrder[$i]] = $dataValueX;
|
||||
}
|
||||
|
||||
$seriesPlot = new StockPlot($dataValues);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
} // function _renderPlotStock()
|
||||
|
||||
|
||||
private function _renderAreaChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotLine($i,True,False,$dimensions);
|
||||
}
|
||||
} // function _renderAreaChart()
|
||||
|
||||
|
||||
private function _renderLineChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotLine($i,False,False,$dimensions);
|
||||
}
|
||||
} // function _renderLineChart()
|
||||
|
||||
|
||||
private function _renderBarChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_bar.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotBar($i,$dimensions);
|
||||
}
|
||||
} // function _renderBarChart()
|
||||
|
||||
|
||||
private function _renderScatterChart($groupCount) {
|
||||
require_once('jpgraph_scatter.php');
|
||||
require_once('jpgraph_regstat.php');
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('linlin');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotScatter($i,false);
|
||||
}
|
||||
} // function _renderScatterChart()
|
||||
|
||||
|
||||
private function _renderBubbleChart($groupCount) {
|
||||
require_once('jpgraph_scatter.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('linlin');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotScatter($i,true);
|
||||
}
|
||||
} // function _renderBubbleChart()
|
||||
|
||||
|
||||
private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
|
||||
require_once('jpgraph_pie.php');
|
||||
if ($dimensions == '3d') {
|
||||
require_once('jpgraph_pie3d.php');
|
||||
}
|
||||
|
||||
$this->_renderPiePlotArea($doughnut);
|
||||
|
||||
$iLimit = ($multiplePlots) ? $groupCount : 1;
|
||||
for($i = 0; $i < $iLimit; ++$i) {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotGrouping();
|
||||
$exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotStyle();
|
||||
if ($i == 0) {
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
if (count($datasetLabels) > 0) {
|
||||
$datasetLabels = $this->_formatDataSetLabels($i,$datasetLabels);
|
||||
}
|
||||
}
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotSeriesCount();
|
||||
$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) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotValuesByIndex($j)->getDataValues();
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$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');
|
||||
}
|
||||
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
$seriesPlot->SetLabels(array_fill(0,count($datasetLabels),''));
|
||||
if ($dimensions != '3d') {
|
||||
$seriesPlot->SetGuideLines(false);
|
||||
}
|
||||
if ($j == 0) {
|
||||
if ($exploded) {
|
||||
$seriesPlot->ExplodeAll();
|
||||
}
|
||||
$seriesPlot->SetLegends($datasetLabels);
|
||||
}
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
}
|
||||
} // function _renderPieChart()
|
||||
|
||||
|
||||
private function _renderRadarChart($groupCount) {
|
||||
require_once('jpgraph_radar.php');
|
||||
|
||||
$this->_renderRadarPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotRadar($i);
|
||||
}
|
||||
} // function _renderRadarChart()
|
||||
|
||||
|
||||
private function _renderStockChart($groupCount) {
|
||||
require_once('jpgraph_stock.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotStock($i);
|
||||
}
|
||||
} // function _renderStockChart()
|
||||
|
||||
|
||||
private function _renderContourChart($groupCount,$dimensions) {
|
||||
require_once('jpgraph_contour.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('intint');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotContour($i);
|
||||
}
|
||||
} // function _renderContourChart()
|
||||
|
||||
|
||||
private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) {
|
||||
require_once('jpgraph_line.php');
|
||||
require_once('jpgraph_bar.php');
|
||||
require_once('jpgraph_scatter.php');
|
||||
require_once('jpgraph_regstat.php');
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$dimensions = null;
|
||||
$chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
switch ($chartType) {
|
||||
case 'area3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'areaChart' :
|
||||
$this->_renderPlotLine($i,True,True,$dimensions);
|
||||
break;
|
||||
case 'bar3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'barChart' :
|
||||
$this->_renderPlotBar($i,$dimensions);
|
||||
break;
|
||||
case 'line3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'lineChart' :
|
||||
$this->_renderPlotLine($i,False,True,$dimensions);
|
||||
break;
|
||||
case 'scatterChart' :
|
||||
$this->_renderPlotScatter($i,false);
|
||||
break;
|
||||
case 'bubbleChart' :
|
||||
$this->_renderPlotScatter($i,true);
|
||||
break;
|
||||
default :
|
||||
$this->_graph = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_renderLegend();
|
||||
|
||||
$this->_graph->Stroke($outputDestination);
|
||||
return true;
|
||||
} // function _renderCombinationChart()
|
||||
|
||||
|
||||
public function render($outputDestination) {
|
||||
$groupCount = $this->_chart->getPlotArea()->getPlotGroupCount();
|
||||
|
||||
$dimensions = null;
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$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 {
|
||||
return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($chartType) {
|
||||
case 'area3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'areaChart' :
|
||||
$this->_renderAreaChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'bar3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'barChart' :
|
||||
$this->_renderBarChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'line3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'lineChart' :
|
||||
$this->_renderLineChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'pie3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'pieChart' :
|
||||
$this->_renderPieChart($groupCount,$dimensions,False,False);
|
||||
break;
|
||||
case 'doughnut3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'doughnutChart' :
|
||||
$this->_renderPieChart($groupCount,$dimensions,True,True);
|
||||
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' :
|
||||
$this->_renderContourChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'stockChart' :
|
||||
$this->_renderStockChart($groupCount,$dimensions);
|
||||
break;
|
||||
default :
|
||||
echo $chartType.' is not yet implemented<br />';
|
||||
return false;
|
||||
}
|
||||
$this->_renderLegend();
|
||||
|
||||
$this->_graph->Stroke($outputDestination);
|
||||
return true;
|
||||
} // function render()
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Renderer_jpgraph
|
||||
*/
|
||||
public function __construct(PHPExcel_Chart $chart)
|
||||
{
|
||||
$this->_graph = null;
|
||||
$this->_chart = $chart;
|
||||
} // function __construct()
|
||||
|
||||
} // PHPExcel_Chart_Renderer_jpgraph
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2011 PHPExcel
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Title
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Caption
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_caption = null;
|
||||
|
||||
/**
|
||||
* Title Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Title
|
||||
*/
|
||||
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
|
||||
{
|
||||
$this->_caption = $caption;
|
||||
$this->_layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get caption
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCaption() {
|
||||
return $this->_caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set caption
|
||||
*
|
||||
* @param string $caption
|
||||
*/
|
||||
public function setCaption($caption = null) {
|
||||
$this->_caption = $caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue