| 1 |
<?php |
| 2 |
|
| 3 |
namespace PhpOffice\PhpSpreadsheet\Chart; |
| 4 |
|
| 5 |
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
| 6 |
|
| 7 |
class PlotArea |
| 8 |
{ |
| 9 |
/** |
| 10 |
* PlotArea Layout. |
| 11 |
* |
| 12 |
* @var Layout |
| 13 |
*/ |
| 14 |
private $layout; |
| 15 |
|
| 16 |
/** |
| 17 |
* Plot Series. |
| 18 |
* |
| 19 |
* @var DataSeries[] |
| 20 |
*/ |
| 21 |
private $plotSeries = []; |
| 22 |
|
| 23 |
/** |
| 24 |
* Create a new PlotArea. |
| 25 |
* |
| 26 |
* @param null|Layout $layout |
| 27 |
* @param DataSeries[] $plotSeries |
| 28 |
*/ |
| 29 |
public function __construct(Layout $layout = null, array $plotSeries = []) |
| 30 |
{ |
| 31 |
$this->layout = $layout; |
| 32 |
$this->plotSeries = $plotSeries; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Get Layout. |
| 37 |
* |
| 38 |
* @return Layout |
| 39 |
*/ |
| 40 |
public function getLayout() |
| 41 |
{ |
| 42 |
return $this->layout; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Get Number of Plot Groups. |
| 47 |
* |
| 48 |
* @return array of DataSeries |
| 49 |
*/ |
| 50 |
public function getPlotGroupCount() |
| 51 |
{ |
| 52 |
return count($this->plotSeries); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get Number of Plot Series. |
| 57 |
* |
| 58 |
* @return int |
| 59 |
*/ |
| 60 |
public function getPlotSeriesCount() |
| 61 |
{ |
| 62 |
$seriesCount = 0; |
| 63 |
foreach ($this->plotSeries as $plot) { |
| 64 |
$seriesCount += $plot->getPlotSeriesCount(); |
| 65 |
} |
| 66 |
|
| 67 |
return $seriesCount; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Get Plot Series. |
| 72 |
* |
| 73 |
* @return array of DataSeries |
| 74 |
*/ |
| 75 |
public function getPlotGroup() |
| 76 |
{ |
| 77 |
return $this->plotSeries; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Get Plot Series by Index. |
| 82 |
* |
| 83 |
* @param mixed $index |
| 84 |
* |
| 85 |
* @return DataSeries |
| 86 |
*/ |
| 87 |
public function getPlotGroupByIndex($index) |
| 88 |
{ |
| 89 |
return $this->plotSeries[$index]; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Set Plot Series. |
| 94 |
* |
| 95 |
* @param DataSeries[] $plotSeries |
| 96 |
* |
| 97 |
* @return PlotArea |
| 98 |
*/ |
| 99 |
public function setPlotSeries(array $plotSeries) |
| 100 |
{ |
| 101 |
$this->plotSeries = $plotSeries; |
| 102 |
|
| 103 |
return $this; |
| 104 |
} |
| 105 |
|
| 106 |
public function refresh(Worksheet $worksheet) |
| 107 |
{ |
| 108 |
foreach ($this->plotSeries as $plotSeries) { |
| 109 |
$plotSeries->refresh($worksheet); |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|