| 1 |
<?php |
| 2 |
|
| 3 |
namespace PhpOffice\PhpSpreadsheet\Chart; |
| 4 |
|
| 5 |
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
| 6 |
|
| 7 |
class PlotArea |
| 8 |
{ |
| 9 |
/** |
| 10 |
* No fill in plot area (show Excel gridlines through chart). |
| 11 |
* |
| 12 |
* @var bool |
| 13 |
*/ |
| 14 |
private $noFill = false; |
| 15 |
|
| 16 |
/** |
| 17 |
* PlotArea Gradient Stop list. |
| 18 |
* Each entry is a 2-element array. |
| 19 |
* First is position in %. |
| 20 |
* Second is ChartColor. |
| 21 |
* |
| 22 |
* @var array[] |
| 23 |
*/ |
| 24 |
private $gradientFillStops = []; |
| 25 |
|
| 26 |
/** |
| 27 |
* PlotArea Gradient Angle. |
| 28 |
* |
| 29 |
* @var ?float |
| 30 |
*/ |
| 31 |
private $gradientFillAngle; |
| 32 |
|
| 33 |
/** |
| 34 |
* PlotArea Layout. |
| 35 |
* |
| 36 |
* @var ?Layout |
| 37 |
*/ |
| 38 |
private $layout; |
| 39 |
|
| 40 |
/** |
| 41 |
* Plot Series. |
| 42 |
* |
| 43 |
* @var DataSeries[] |
| 44 |
*/ |
| 45 |
private $plotSeries = []; |
| 46 |
|
| 47 |
/** |
| 48 |
* Create a new PlotArea. |
| 49 |
* |
| 50 |
* @param DataSeries[] $plotSeries |
| 51 |
*/ |
| 52 |
public function __construct(?Layout $layout = null, array $plotSeries = []) |
| 53 |
{ |
| 54 |
$this->layout = $layout; |
| 55 |
$this->plotSeries = $plotSeries; |
| 56 |
} |
| 57 |
|
| 58 |
public function getLayout(): ?Layout |
| 59 |
{ |
| 60 |
return $this->layout; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Get Number of Plot Groups. |
| 65 |
*/ |
| 66 |
public function getPlotGroupCount(): int |
| 67 |
{ |
| 68 |
return count($this->plotSeries); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Get Number of Plot Series. |
| 73 |
* |
| 74 |
* @return int |
| 75 |
*/ |
| 76 |
public function getPlotSeriesCount() |
| 77 |
{ |
| 78 |
$seriesCount = 0; |
| 79 |
foreach ($this->plotSeries as $plot) { |
| 80 |
$seriesCount += $plot->getPlotSeriesCount(); |
| 81 |
} |
| 82 |
|
| 83 |
return $seriesCount; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Get Plot Series. |
| 88 |
* |
| 89 |
* @return DataSeries[] |
| 90 |
*/ |
| 91 |
public function getPlotGroup() |
| 92 |
{ |
| 93 |
return $this->plotSeries; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Get Plot Series by Index. |
| 98 |
* |
| 99 |
* @param mixed $index |
| 100 |
* |
| 101 |
* @return DataSeries |
| 102 |
*/ |
| 103 |
public function getPlotGroupByIndex($index) |
| 104 |
{ |
| 105 |
return $this->plotSeries[$index]; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Set Plot Series. |
| 110 |
* |
| 111 |
* @param DataSeries[] $plotSeries |
| 112 |
* |
| 113 |
* @return $this |
| 114 |
*/ |
| 115 |
public function setPlotSeries(array $plotSeries) |
| 116 |
{ |
| 117 |
$this->plotSeries = $plotSeries; |
| 118 |
|
| 119 |
return $this; |
| 120 |
} |
| 121 |
|
| 122 |
public function refresh(Worksheet $worksheet): void |
| 123 |
{ |
| 124 |
foreach ($this->plotSeries as $plotSeries) { |
| 125 |
$plotSeries->refresh($worksheet); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
public function setNoFill(bool $noFill): self |
| 130 |
{ |
| 131 |
$this->noFill = $noFill; |
| 132 |
|
| 133 |
return $this; |
| 134 |
} |
| 135 |
|
| 136 |
public function getNoFill(): bool |
| 137 |
{ |
| 138 |
return $this->noFill; |
| 139 |
} |
| 140 |
|
| 141 |
public function setGradientFillProperties(array $gradientFillStops, ?float $gradientFillAngle): self |
| 142 |
{ |
| 143 |
$this->gradientFillStops = $gradientFillStops; |
| 144 |
$this->gradientFillAngle = $gradientFillAngle; |
| 145 |
|
| 146 |
return $this; |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* Get gradientFillAngle. |
| 151 |
*/ |
| 152 |
public function getGradientFillAngle(): ?float |
| 153 |
{ |
| 154 |
return $this->gradientFillAngle; |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* Get gradientFillStops. |
| 159 |
* |
| 160 |
* @return array |
| 161 |
*/ |
| 162 |
public function getGradientFillStops() |
| 163 |
{ |
| 164 |
return $this->gradientFillStops; |
| 165 |
} |
| 166 |
|
| 167 |
/** @var ?int */ |
| 168 |
private $gapWidth; |
| 169 |
|
| 170 |
/** @var bool */ |
| 171 |
private $useUpBars = false; |
| 172 |
|
| 173 |
/** @var bool */ |
| 174 |
private $useDownBars = false; |
| 175 |
|
| 176 |
public function getGapWidth(): ?int |
| 177 |
{ |
| 178 |
return $this->gapWidth; |
| 179 |
} |
| 180 |
|
| 181 |
public function setGapWidth(?int $gapWidth): self |
| 182 |
{ |
| 183 |
$this->gapWidth = $gapWidth; |
| 184 |
|
| 185 |
return $this; |
| 186 |
} |
| 187 |
|
| 188 |
public function getUseUpBars(): bool |
| 189 |
{ |
| 190 |
return $this->useUpBars; |
| 191 |
} |
| 192 |
|
| 193 |
public function setUseUpBars(bool $useUpBars): self |
| 194 |
{ |
| 195 |
$this->useUpBars = $useUpBars; |
| 196 |
|
| 197 |
return $this; |
| 198 |
} |
| 199 |
|
| 200 |
public function getUseDownBars(): bool |
| 201 |
{ |
| 202 |
return $this->useDownBars; |
| 203 |
} |
| 204 |
|
| 205 |
public function setUseDownBars(bool $useDownBars): self |
| 206 |
{ |
| 207 |
$this->useDownBars = $useDownBars; |
| 208 |
|
| 209 |
return $this; |
| 210 |
} |
| 211 |
} |
| 212 |
|