PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Chart / PlotArea.php

PlotArea.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Chart/PlotArea.php

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