Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Chart; 4 5 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; 6 7 class DataSeries 8 { 9 const TYPE_BARCHART = 'barChart'; 10 const TYPE_BARCHART_3D = 'bar3DChart'; 11 const TYPE_LINECHART = 'lineChart'; 12 const TYPE_LINECHART_3D = 'line3DChart'; 13 const TYPE_AREACHART = 'areaChart'; 14 const TYPE_AREACHART_3D = 'area3DChart'; 15 const TYPE_PIECHART = 'pieChart'; 16 const TYPE_PIECHART_3D = 'pie3DChart'; 17 const TYPE_DOUGHNUTCHART = 'doughnutChart'; 18 const TYPE_DONUTCHART = self::TYPE_DOUGHNUTCHART; // Synonym 19 const TYPE_SCATTERCHART = 'scatterChart'; 20 const TYPE_SURFACECHART = 'surfaceChart'; 21 const TYPE_SURFACECHART_3D = 'surface3DChart'; 22 const TYPE_RADARCHART = 'radarChart'; 23 const TYPE_BUBBLECHART = 'bubbleChart'; 24 const TYPE_STOCKCHART = 'stockChart'; 25 const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym 26 27 const GROUPING_CLUSTERED = 'clustered'; 28 const GROUPING_STACKED = 'stacked'; 29 const GROUPING_PERCENT_STACKED = 'percentStacked'; 30 const GROUPING_STANDARD = 'standard'; 31 32 const DIRECTION_BAR = 'bar'; 33 const DIRECTION_HORIZONTAL = self::DIRECTION_BAR; 34 const DIRECTION_COL = 'col'; 35 const DIRECTION_COLUMN = self::DIRECTION_COL; 36 const DIRECTION_VERTICAL = self::DIRECTION_COL; 37 38 const STYLE_LINEMARKER = 'lineMarker'; 39 const STYLE_SMOOTHMARKER = 'smoothMarker'; 40 const STYLE_MARKER = 'marker'; 41 const STYLE_FILLED = 'filled'; 42 43 const EMPTY_AS_GAP = 'gap'; 44 const EMPTY_AS_ZERO = 'zero'; 45 const EMPTY_AS_SPAN = 'span'; 46 47 /** 48 * Series Plot Type. 49 * 50 * @var string 51 */ 52 private $plotType; 53 54 /** 55 * Plot Grouping Type. 56 * 57 * @var string 58 */ 59 private $plotGrouping; 60 61 /** 62 * Plot Direction. 63 * 64 * @var string 65 */ 66 private $plotDirection; 67 68 /** 69 * Plot Style. 70 * 71 * @var null|string 72 */ 73 private $plotStyle; 74 75 /** 76 * Order of plots in Series. 77 * 78 * @var array of integer 79 */ 80 private $plotOrder = []; 81 82 /** 83 * Plot Label. 84 * 85 * @var array of DataSeriesValues 86 */ 87 private $plotLabel = []; 88 89 /** 90 * Plot Category. 91 * 92 * @var array of DataSeriesValues 93 */ 94 private $plotCategory = []; 95 96 /** 97 * Smooth Line. 98 * 99 * @var bool 100 */ 101 private $smoothLine; 102 103 /** 104 * Plot Values. 105 * 106 * @var array of DataSeriesValues 107 */ 108 private $plotValues = []; 109 110 /** 111 * Create a new DataSeries. 112 * 113 * @param null|mixed $plotType 114 * @param null|mixed $plotGrouping 115 * @param int[] $plotOrder 116 * @param DataSeriesValues[] $plotLabel 117 * @param DataSeriesValues[] $plotCategory 118 * @param DataSeriesValues[] $plotValues 119 * @param null|string $plotDirection 120 * @param bool $smoothLine 121 * @param null|string $plotStyle 122 */ 123 public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null) 124 { 125 $this->plotType = $plotType; 126 $this->plotGrouping = $plotGrouping; 127 $this->plotOrder = $plotOrder; 128 $keys = array_keys($plotValues); 129 $this->plotValues = $plotValues; 130 if ((count($plotLabel) == 0) || ($plotLabel[$keys[0]] === null)) { 131 $plotLabel[$keys[0]] = new DataSeriesValues(); 132 } 133 $this->plotLabel = $plotLabel; 134 135 if ((count($plotCategory) == 0) || ($plotCategory[$keys[0]] === null)) { 136 $plotCategory[$keys[0]] = new DataSeriesValues(); 137 } 138 $this->plotCategory = $plotCategory; 139 140 $this->smoothLine = $smoothLine; 141 $this->plotStyle = $plotStyle; 142 143 if ($plotDirection === null) { 144 $plotDirection = self::DIRECTION_COL; 145 } 146 $this->plotDirection = $plotDirection; 147 } 148 149 /** 150 * Get Plot Type. 151 * 152 * @return string 153 */ 154 public function getPlotType() 155 { 156 return $this->plotType; 157 } 158 159 /** 160 * Set Plot Type. 161 * 162 * @param string $plotType 163 * 164 * @return $this 165 */ 166 public function setPlotType($plotType) 167 { 168 $this->plotType = $plotType; 169 170 return $this; 171 } 172 173 /** 174 * Get Plot Grouping Type. 175 * 176 * @return string 177 */ 178 public function getPlotGrouping() 179 { 180 return $this->plotGrouping; 181 } 182 183 /** 184 * Set Plot Grouping Type. 185 * 186 * @param string $groupingType 187 * 188 * @return $this 189 */ 190 public function setPlotGrouping($groupingType) 191 { 192 $this->plotGrouping = $groupingType; 193 194 return $this; 195 } 196 197 /** 198 * Get Plot Direction. 199 * 200 * @return string 201 */ 202 public function getPlotDirection() 203 { 204 return $this->plotDirection; 205 } 206 207 /** 208 * Set Plot Direction. 209 * 210 * @param string $plotDirection 211 * 212 * @return $this 213 */ 214 public function setPlotDirection($plotDirection) 215 { 216 $this->plotDirection = $plotDirection; 217 218 return $this; 219 } 220 221 /** 222 * Get Plot Order. 223 * 224 * @return int[] 225 */ 226 public function getPlotOrder() 227 { 228 return $this->plotOrder; 229 } 230 231 /** 232 * Get Plot Labels. 233 * 234 * @return array of DataSeriesValues 235 */ 236 public function getPlotLabels() 237 { 238 return $this->plotLabel; 239 } 240 241 /** 242 * Get Plot Label by Index. 243 * 244 * @param mixed $index 245 * 246 * @return DataSeriesValues 247 */ 248 public function getPlotLabelByIndex($index) 249 { 250 $keys = array_keys($this->plotLabel); 251 if (in_array($index, $keys)) { 252 return $this->plotLabel[$index]; 253 } elseif (isset($keys[$index])) { 254 return $this->plotLabel[$keys[$index]]; 255 } 256 257 return false; 258 } 259 260 /** 261 * Get Plot Categories. 262 * 263 * @return array of DataSeriesValues 264 */ 265 public function getPlotCategories() 266 { 267 return $this->plotCategory; 268 } 269 270 /** 271 * Get Plot Category by Index. 272 * 273 * @param mixed $index 274 * 275 * @return DataSeriesValues 276 */ 277 public function getPlotCategoryByIndex($index) 278 { 279 $keys = array_keys($this->plotCategory); 280 if (in_array($index, $keys)) { 281 return $this->plotCategory[$index]; 282 } elseif (isset($keys[$index])) { 283 return $this->plotCategory[$keys[$index]]; 284 } 285 286 return false; 287 } 288 289 /** 290 * Get Plot Style. 291 * 292 * @return null|string 293 */ 294 public function getPlotStyle() 295 { 296 return $this->plotStyle; 297 } 298 299 /** 300 * Set Plot Style. 301 * 302 * @param null|string $plotStyle 303 * 304 * @return $this 305 */ 306 public function setPlotStyle($plotStyle) 307 { 308 $this->plotStyle = $plotStyle; 309 310 return $this; 311 } 312 313 /** 314 * Get Plot Values. 315 * 316 * @return array of DataSeriesValues 317 */ 318 public function getPlotValues() 319 { 320 return $this->plotValues; 321 } 322 323 /** 324 * Get Plot Values by Index. 325 * 326 * @param mixed $index 327 * 328 * @return DataSeriesValues 329 */ 330 public function getPlotValuesByIndex($index) 331 { 332 $keys = array_keys($this->plotValues); 333 if (in_array($index, $keys)) { 334 return $this->plotValues[$index]; 335 } elseif (isset($keys[$index])) { 336 return $this->plotValues[$keys[$index]]; 337 } 338 339 return false; 340 } 341 342 /** 343 * Get Number of Plot Series. 344 * 345 * @return int 346 */ 347 public function getPlotSeriesCount() 348 { 349 return count($this->plotValues); 350 } 351 352 /** 353 * Get Smooth Line. 354 * 355 * @return bool 356 */ 357 public function getSmoothLine() 358 { 359 return $this->smoothLine; 360 } 361 362 /** 363 * Set Smooth Line. 364 * 365 * @param bool $smoothLine 366 * 367 * @return $this 368 */ 369 public function setSmoothLine($smoothLine) 370 { 371 $this->smoothLine = $smoothLine; 372 373 return $this; 374 } 375 376 public function refresh(Worksheet $worksheet): void 377 { 378 foreach ($this->plotValues as $plotValues) { 379 if ($plotValues !== null) { 380 $plotValues->refresh($worksheet, true); 381 } 382 } 383 foreach ($this->plotLabel as $plotValues) { 384 if ($plotValues !== null) { 385 $plotValues->refresh($worksheet, true); 386 } 387 } 388 foreach ($this->plotCategory as $plotValues) { 389 if ($plotValues !== null) { 390 $plotValues->refresh($worksheet, false); 391 } 392 } 393 } 394 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body