| 1 |
<?php |
| 2 |
/** |
| 3 |
* PHPExcel |
| 4 |
* |
| 5 |
* Copyright (c) 2006 - 2014 PHPExcel |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this library; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
* |
| 21 |
* @category PHPExcel |
| 22 |
* @package PHPExcel_Chart |
| 23 |
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) |
| 24 |
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
| 25 |
* @version ##VERSION##, ##DATE## |
| 26 |
*/ |
| 27 |
|
| 28 |
|
| 29 |
/** |
| 30 |
* PHPExcel_Chart_DataSeries |
| 31 |
* |
| 32 |
* @category PHPExcel |
| 33 |
* @package PHPExcel_Chart |
| 34 |
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) |
| 35 |
*/ |
| 36 |
class PHPExcel_Chart_DataSeries |
| 37 |
{ |
| 38 |
|
| 39 |
const TYPE_BARCHART = 'barChart'; |
| 40 |
const TYPE_BARCHART_3D = 'bar3DChart'; |
| 41 |
const TYPE_LINECHART = 'lineChart'; |
| 42 |
const TYPE_LINECHART_3D = 'line3DChart'; |
| 43 |
const TYPE_AREACHART = 'areaChart'; |
| 44 |
const TYPE_AREACHART_3D = 'area3DChart'; |
| 45 |
const TYPE_PIECHART = 'pieChart'; |
| 46 |
const TYPE_PIECHART_3D = 'pie3DChart'; |
| 47 |
const TYPE_DOUGHTNUTCHART = 'doughnutChart'; |
| 48 |
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym |
| 49 |
const TYPE_SCATTERCHART = 'scatterChart'; |
| 50 |
const TYPE_SURFACECHART = 'surfaceChart'; |
| 51 |
const TYPE_SURFACECHART_3D = 'surface3DChart'; |
| 52 |
const TYPE_RADARCHART = 'radarChart'; |
| 53 |
const TYPE_BUBBLECHART = 'bubbleChart'; |
| 54 |
const TYPE_STOCKCHART = 'stockChart'; |
| 55 |
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym |
| 56 |
|
| 57 |
const GROUPING_CLUSTERED = 'clustered'; |
| 58 |
const GROUPING_STACKED = 'stacked'; |
| 59 |
const GROUPING_PERCENT_STACKED = 'percentStacked'; |
| 60 |
const GROUPING_STANDARD = 'standard'; |
| 61 |
|
| 62 |
const DIRECTION_BAR = 'bar'; |
| 63 |
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR; |
| 64 |
const DIRECTION_COL = 'col'; |
| 65 |
const DIRECTION_COLUMN = self::DIRECTION_COL; |
| 66 |
const DIRECTION_VERTICAL = self::DIRECTION_COL; |
| 67 |
|
| 68 |
const STYLE_LINEMARKER = 'lineMarker'; |
| 69 |
const STYLE_SMOOTHMARKER = 'smoothMarker'; |
| 70 |
const STYLE_MARKER = 'marker'; |
| 71 |
const STYLE_FILLED = 'filled'; |
| 72 |
|
| 73 |
|
| 74 |
/** |
| 75 |
* Series Plot Type |
| 76 |
* |
| 77 |
* @var string |
| 78 |
*/ |
| 79 |
private $_plotType = null; |
| 80 |
|
| 81 |
/** |
| 82 |
* Plot Grouping Type |
| 83 |
* |
| 84 |
* @var boolean |
| 85 |
*/ |
| 86 |
private $_plotGrouping = null; |
| 87 |
|
| 88 |
/** |
| 89 |
* Plot Direction |
| 90 |
* |
| 91 |
* @var boolean |
| 92 |
*/ |
| 93 |
private $_plotDirection = null; |
| 94 |
|
| 95 |
/** |
| 96 |
* Plot Style |
| 97 |
* |
| 98 |
* @var string |
| 99 |
*/ |
| 100 |
private $_plotStyle = null; |
| 101 |
|
| 102 |
/** |
| 103 |
* Order of plots in Series |
| 104 |
* |
| 105 |
* @var array of integer |
| 106 |
*/ |
| 107 |
private $_plotOrder = array(); |
| 108 |
|
| 109 |
/** |
| 110 |
* Plot Label |
| 111 |
* |
| 112 |
* @var array of PHPExcel_Chart_DataSeriesValues |
| 113 |
*/ |
| 114 |
private $_plotLabel = array(); |
| 115 |
|
| 116 |
/** |
| 117 |
* Plot Category |
| 118 |
* |
| 119 |
* @var array of PHPExcel_Chart_DataSeriesValues |
| 120 |
*/ |
| 121 |
private $_plotCategory = array(); |
| 122 |
|
| 123 |
/** |
| 124 |
* Smooth Line |
| 125 |
* |
| 126 |
* @var string |
| 127 |
*/ |
| 128 |
private $_smoothLine = null; |
| 129 |
|
| 130 |
/** |
| 131 |
* Plot Values |
| 132 |
* |
| 133 |
* @var array of PHPExcel_Chart_DataSeriesValues |
| 134 |
*/ |
| 135 |
private $_plotValues = array(); |
| 136 |
|
| 137 |
/** |
| 138 |
* Create a new PHPExcel_Chart_DataSeries |
| 139 |
*/ |
| 140 |
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null) |
| 141 |
{ |
| 142 |
$this->_plotType = $plotType; |
| 143 |
$this->_plotGrouping = $plotGrouping; |
| 144 |
$this->_plotOrder = $plotOrder; |
| 145 |
$keys = array_keys($plotValues); |
| 146 |
$this->_plotValues = $plotValues; |
| 147 |
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) { |
| 148 |
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); |
| 149 |
} |
| 150 |
|
| 151 |
$this->_plotLabel = $plotLabel; |
| 152 |
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) { |
| 153 |
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); |
| 154 |
} |
| 155 |
$this->_plotCategory = $plotCategory; |
| 156 |
$this->_smoothLine = $smoothLine; |
| 157 |
$this->_plotStyle = $plotStyle; |
| 158 |
|
| 159 |
if (is_null($plotDirection)) { |
| 160 |
$plotDirection = self::DIRECTION_COL; |
| 161 |
} |
| 162 |
$this->_plotDirection = $plotDirection; |
| 163 |
} |
| 164 |
|
| 165 |
/** |
| 166 |
* Get Plot Type |
| 167 |
* |
| 168 |
* @return string |
| 169 |
*/ |
| 170 |
public function getPlotType() { |
| 171 |
return $this->_plotType; |
| 172 |
} |
| 173 |
|
| 174 |
/** |
| 175 |
* Set Plot Type |
| 176 |
* |
| 177 |
* @param string $plotType |
| 178 |
* @return PHPExcel_Chart_DataSeries |
| 179 |
*/ |
| 180 |
public function setPlotType($plotType = '') { |
| 181 |
$this->_plotType = $plotType; |
| 182 |
return $this; |
| 183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* Get Plot Grouping Type |
| 187 |
* |
| 188 |
* @return string |
| 189 |
*/ |
| 190 |
public function getPlotGrouping() { |
| 191 |
return $this->_plotGrouping; |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Set Plot Grouping Type |
| 196 |
* |
| 197 |
* @param string $groupingType |
| 198 |
* @return PHPExcel_Chart_DataSeries |
| 199 |
*/ |
| 200 |
public function setPlotGrouping($groupingType = null) { |
| 201 |
$this->_plotGrouping = $groupingType; |
| 202 |
return $this; |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* Get Plot Direction |
| 207 |
* |
| 208 |
* @return string |
| 209 |
*/ |
| 210 |
public function getPlotDirection() { |
| 211 |
return $this->_plotDirection; |
| 212 |
} |
| 213 |
|
| 214 |
/** |
| 215 |
* Set Plot Direction |
| 216 |
* |
| 217 |
* @param string $plotDirection |
| 218 |
* @return PHPExcel_Chart_DataSeries |
| 219 |
*/ |
| 220 |
public function setPlotDirection($plotDirection = null) { |
| 221 |
$this->_plotDirection = $plotDirection; |
| 222 |
return $this; |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* Get Plot Order |
| 227 |
* |
| 228 |
* @return string |
| 229 |
*/ |
| 230 |
public function getPlotOrder() { |
| 231 |
return $this->_plotOrder; |
| 232 |
} |
| 233 |
|
| 234 |
/** |
| 235 |
* Get Plot Labels |
| 236 |
* |
| 237 |
* @return array of PHPExcel_Chart_DataSeriesValues |
| 238 |
*/ |
| 239 |
public function getPlotLabels() { |
| 240 |
return $this->_plotLabel; |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Get Plot Label by Index |
| 245 |
* |
| 246 |
* @return PHPExcel_Chart_DataSeriesValues |
| 247 |
*/ |
| 248 |
public function getPlotLabelByIndex($index) { |
| 249 |
$keys = array_keys($this->_plotLabel); |
| 250 |
if (in_array($index,$keys)) { |
| 251 |
return $this->_plotLabel[$index]; |
| 252 |
} elseif(isset($keys[$index])) { |
| 253 |
return $this->_plotLabel[$keys[$index]]; |
| 254 |
} |
| 255 |
return false; |
| 256 |
} |
| 257 |
|
| 258 |
/** |
| 259 |
* Get Plot Categories |
| 260 |
* |
| 261 |
* @return array of PHPExcel_Chart_DataSeriesValues |
| 262 |
*/ |
| 263 |
public function getPlotCategories() { |
| 264 |
return $this->_plotCategory; |
| 265 |
} |
| 266 |
|
| 267 |
/** |
| 268 |
* Get Plot Category by Index |
| 269 |
* |
| 270 |
* @return PHPExcel_Chart_DataSeriesValues |
| 271 |
*/ |
| 272 |
public function getPlotCategoryByIndex($index) { |
| 273 |
$keys = array_keys($this->_plotCategory); |
| 274 |
if (in_array($index,$keys)) { |
| 275 |
return $this->_plotCategory[$index]; |
| 276 |
} elseif(isset($keys[$index])) { |
| 277 |
return $this->_plotCategory[$keys[$index]]; |
| 278 |
} |
| 279 |
return false; |
| 280 |
} |
| 281 |
|
| 282 |
/** |
| 283 |
* Get Plot Style |
| 284 |
* |
| 285 |
* @return string |
| 286 |
*/ |
| 287 |
public function getPlotStyle() { |
| 288 |
return $this->_plotStyle; |
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* Set Plot Style |
| 293 |
* |
| 294 |
* @param string $plotStyle |
| 295 |
* @return PHPExcel_Chart_DataSeries |
| 296 |
*/ |
| 297 |
public function setPlotStyle($plotStyle = null) { |
| 298 |
$this->_plotStyle = $plotStyle; |
| 299 |
return $this; |
| 300 |
} |
| 301 |
|
| 302 |
/** |
| 303 |
* Get Plot Values |
| 304 |
* |
| 305 |
* @return array of PHPExcel_Chart_DataSeriesValues |
| 306 |
*/ |
| 307 |
public function getPlotValues() { |
| 308 |
return $this->_plotValues; |
| 309 |
} |
| 310 |
|
| 311 |
/** |
| 312 |
* Get Plot Values by Index |
| 313 |
* |
| 314 |
* @return PHPExcel_Chart_DataSeriesValues |
| 315 |
*/ |
| 316 |
public function getPlotValuesByIndex($index) { |
| 317 |
$keys = array_keys($this->_plotValues); |
| 318 |
if (in_array($index,$keys)) { |
| 319 |
return $this->_plotValues[$index]; |
| 320 |
} elseif(isset($keys[$index])) { |
| 321 |
return $this->_plotValues[$keys[$index]]; |
| 322 |
} |
| 323 |
return false; |
| 324 |
} |
| 325 |
|
| 326 |
/** |
| 327 |
* Get Number of Plot Series |
| 328 |
* |
| 329 |
* @return integer |
| 330 |
*/ |
| 331 |
public function getPlotSeriesCount() { |
| 332 |
return count($this->_plotValues); |
| 333 |
} |
| 334 |
|
| 335 |
/** |
| 336 |
* Get Smooth Line |
| 337 |
* |
| 338 |
* @return boolean |
| 339 |
*/ |
| 340 |
public function getSmoothLine() { |
| 341 |
return $this->_smoothLine; |
| 342 |
} |
| 343 |
|
| 344 |
/** |
| 345 |
* Set Smooth Line |
| 346 |
* |
| 347 |
* @param boolean $smoothLine |
| 348 |
* @return PHPExcel_Chart_DataSeries |
| 349 |
*/ |
| 350 |
public function setSmoothLine($smoothLine = TRUE) { |
| 351 |
$this->_smoothLine = $smoothLine; |
| 352 |
return $this; |
| 353 |
} |
| 354 |
|
| 355 |
public function refresh(PHPExcel_Worksheet $worksheet) { |
| 356 |
foreach($this->_plotValues as $plotValues) { |
| 357 |
if ($plotValues !== NULL) |
| 358 |
$plotValues->refresh($worksheet, TRUE); |
| 359 |
} |
| 360 |
foreach($this->_plotLabel as $plotValues) { |
| 361 |
if ($plotValues !== NULL) |
| 362 |
$plotValues->refresh($worksheet, TRUE); |
| 363 |
} |
| 364 |
foreach($this->_plotCategory as $plotValues) { |
| 365 |
if ($plotValues !== NULL) |
| 366 |
$plotValues->refresh($worksheet, FALSE); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
} |
| 371 |
|