PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Chart / DataSeries.php

DataSeries.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.7.1, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php

391 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 /**
44 * Series Plot Type.
45 *
46 * @var string
47 */
48 private $plotType;
49
50 /**
51 * Plot Grouping Type.
52 *
53 * @var string
54 */
55 private $plotGrouping;
56
57 /**
58 * Plot Direction.
59 *
60 * @var string
61 */
62 private $plotDirection;
63
64 /**
65 * Plot Style.
66 *
67 * @var null|string
68 */
69 private $plotStyle;
70
71 /**
72 * Order of plots in Series.
73 *
74 * @var array of integer
75 */
76 private $plotOrder = [];
77
78 /**
79 * Plot Label.
80 *
81 * @var array of DataSeriesValues
82 */
83 private $plotLabel = [];
84
85 /**
86 * Plot Category.
87 *
88 * @var array of DataSeriesValues
89 */
90 private $plotCategory = [];
91
92 /**
93 * Smooth Line.
94 *
95 * @var bool
96 */
97 private $smoothLine;
98
99 /**
100 * Plot Values.
101 *
102 * @var array of DataSeriesValues
103 */
104 private $plotValues = [];
105
106 /**
107 * Create a new DataSeries.
108 *
109 * @param null|mixed $plotType
110 * @param null|mixed $plotGrouping
111 * @param int[] $plotOrder
112 * @param DataSeriesValues[] $plotLabel
113 * @param DataSeriesValues[] $plotCategory
114 * @param DataSeriesValues[] $plotValues
115 * @param null|string $plotDirection
116 * @param bool $smoothLine
117 * @param null|string $plotStyle
118 */
119 public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null)
120 {
121 $this->plotType = $plotType;
122 $this->plotGrouping = $plotGrouping;
123 $this->plotOrder = $plotOrder;
124 $keys = array_keys($plotValues);
125 $this->plotValues = $plotValues;
126 if ((count($plotLabel) == 0) || ($plotLabel[$keys[0]] === null)) {
127 $plotLabel[$keys[0]] = new DataSeriesValues();
128 }
129 $this->plotLabel = $plotLabel;
130
131 if ((count($plotCategory) == 0) || ($plotCategory[$keys[0]] === null)) {
132 $plotCategory[$keys[0]] = new DataSeriesValues();
133 }
134 $this->plotCategory = $plotCategory;
135
136 $this->smoothLine = $smoothLine;
137 $this->plotStyle = $plotStyle;
138
139 if ($plotDirection === null) {
140 $plotDirection = self::DIRECTION_COL;
141 }
142 $this->plotDirection = $plotDirection;
143 }
144
145 /**
146 * Get Plot Type.
147 *
148 * @return string
149 */
150 public function getPlotType()
151 {
152 return $this->plotType;
153 }
154
155 /**
156 * Set Plot Type.
157 *
158 * @param string $plotType
159 *
160 * @return DataSeries
161 */
162 public function setPlotType($plotType)
163 {
164 $this->plotType = $plotType;
165
166 return $this;
167 }
168
169 /**
170 * Get Plot Grouping Type.
171 *
172 * @return string
173 */
174 public function getPlotGrouping()
175 {
176 return $this->plotGrouping;
177 }
178
179 /**
180 * Set Plot Grouping Type.
181 *
182 * @param string $groupingType
183 *
184 * @return DataSeries
185 */
186 public function setPlotGrouping($groupingType)
187 {
188 $this->plotGrouping = $groupingType;
189
190 return $this;
191 }
192
193 /**
194 * Get Plot Direction.
195 *
196 * @return string
197 */
198 public function getPlotDirection()
199 {
200 return $this->plotDirection;
201 }
202
203 /**
204 * Set Plot Direction.
205 *
206 * @param string $plotDirection
207 *
208 * @return DataSeries
209 */
210 public function setPlotDirection($plotDirection)
211 {
212 $this->plotDirection = $plotDirection;
213
214 return $this;
215 }
216
217 /**
218 * Get Plot Order.
219 *
220 * @return int[]
221 */
222 public function getPlotOrder()
223 {
224 return $this->plotOrder;
225 }
226
227 /**
228 * Get Plot Labels.
229 *
230 * @return array of DataSeriesValues
231 */
232 public function getPlotLabels()
233 {
234 return $this->plotLabel;
235 }
236
237 /**
238 * Get Plot Label by Index.
239 *
240 * @param mixed $index
241 *
242 * @return DataSeriesValues
243 */
244 public function getPlotLabelByIndex($index)
245 {
246 $keys = array_keys($this->plotLabel);
247 if (in_array($index, $keys)) {
248 return $this->plotLabel[$index];
249 } elseif (isset($keys[$index])) {
250 return $this->plotLabel[$keys[$index]];
251 }
252
253 return false;
254 }
255
256 /**
257 * Get Plot Categories.
258 *
259 * @return array of DataSeriesValues
260 */
261 public function getPlotCategories()
262 {
263 return $this->plotCategory;
264 }
265
266 /**
267 * Get Plot Category by Index.
268 *
269 * @param mixed $index
270 *
271 * @return DataSeriesValues
272 */
273 public function getPlotCategoryByIndex($index)
274 {
275 $keys = array_keys($this->plotCategory);
276 if (in_array($index, $keys)) {
277 return $this->plotCategory[$index];
278 } elseif (isset($keys[$index])) {
279 return $this->plotCategory[$keys[$index]];
280 }
281
282 return false;
283 }
284
285 /**
286 * Get Plot Style.
287 *
288 * @return null|string
289 */
290 public function getPlotStyle()
291 {
292 return $this->plotStyle;
293 }
294
295 /**
296 * Set Plot Style.
297 *
298 * @param null|string $plotStyle
299 *
300 * @return DataSeries
301 */
302 public function setPlotStyle($plotStyle)
303 {
304 $this->plotStyle = $plotStyle;
305
306 return $this;
307 }
308
309 /**
310 * Get Plot Values.
311 *
312 * @return array of DataSeriesValues
313 */
314 public function getPlotValues()
315 {
316 return $this->plotValues;
317 }
318
319 /**
320 * Get Plot Values by Index.
321 *
322 * @param mixed $index
323 *
324 * @return DataSeriesValues
325 */
326 public function getPlotValuesByIndex($index)
327 {
328 $keys = array_keys($this->plotValues);
329 if (in_array($index, $keys)) {
330 return $this->plotValues[$index];
331 } elseif (isset($keys[$index])) {
332 return $this->plotValues[$keys[$index]];
333 }
334
335 return false;
336 }
337
338 /**
339 * Get Number of Plot Series.
340 *
341 * @return int
342 */
343 public function getPlotSeriesCount()
344 {
345 return count($this->plotValues);
346 }
347
348 /**
349 * Get Smooth Line.
350 *
351 * @return bool
352 */
353 public function getSmoothLine()
354 {
355 return $this->smoothLine;
356 }
357
358 /**
359 * Set Smooth Line.
360 *
361 * @param bool $smoothLine
362 *
363 * @return DataSeries
364 */
365 public function setSmoothLine($smoothLine)
366 {
367 $this->smoothLine = $smoothLine;
368
369 return $this;
370 }
371
372 public function refresh(Worksheet $worksheet)
373 {
374 foreach ($this->plotValues as $plotValues) {
375 if ($plotValues !== null) {
376 $plotValues->refresh($worksheet, true);
377 }
378 }
379 foreach ($this->plotLabel as $plotValues) {
380 if ($plotValues !== null) {
381 $plotValues->refresh($worksheet, true);
382 }
383 }
384 foreach ($this->plotCategory as $plotValues) {
385 if ($plotValues !== null) {
386 $plotValues->refresh($worksheet, false);
387 }
388 }
389 }
390 }
391