PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.3
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 / phpexcel / Classes / PHPExcel / Chart.php

Chart.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.0.3, at vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart.php

636 lines 12.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHPExcel
4 *
5 * Copyright (c) 2006 - 2014 PHPExcel
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 * @category PHPExcel
22 * @package PHPExcel_Chart
23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
26 */
27
28
29 /**
30 * PHPExcel_Chart
31 *
32 * @category PHPExcel
33 * @package PHPExcel_Chart
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 */
36 class PHPExcel_Chart
37 {
38 /**
39 * Chart Name
40 *
41 * @var string
42 */
43 private $_name = '';
44
45 /**
46 * Worksheet
47 *
48 * @var PHPExcel_Worksheet
49 */
50 private $_worksheet = null;
51
52 /**
53 * Chart Title
54 *
55 * @var PHPExcel_Chart_Title
56 */
57 private $_title = null;
58
59 /**
60 * Chart Legend
61 *
62 * @var PHPExcel_Chart_Legend
63 */
64 private $_legend = null;
65
66 /**
67 * X-Axis Label
68 *
69 * @var PHPExcel_Chart_Title
70 */
71 private $_xAxisLabel = null;
72
73 /**
74 * Y-Axis Label
75 *
76 * @var PHPExcel_Chart_Title
77 */
78 private $_yAxisLabel = null;
79
80 /**
81 * Chart Plot Area
82 *
83 * @var PHPExcel_Chart_PlotArea
84 */
85 private $_plotArea = null;
86
87 /**
88 * Plot Visible Only
89 *
90 * @var boolean
91 */
92 private $_plotVisibleOnly = true;
93
94 /**
95 * Display Blanks as
96 *
97 * @var string
98 */
99 private $_displayBlanksAs = '0';
100
101 /**
102 * Chart Asix Y as
103 *
104 * @var PHPExcel_Chart_Axis
105 */
106 private $_yAxis = null;
107
108 /**
109 * Chart Asix X as
110 *
111 * @var PHPExcel_Chart_Axis
112 */
113 private $_xAxis = null;
114
115 /**
116 * Chart Major Gridlines as
117 *
118 * @var PHPExcel_Chart_GridLines
119 */
120 private $_majorGridlines = null;
121
122 /**
123 * Chart Minor Gridlines as
124 *
125 * @var PHPExcel_Chart_GridLines
126 */
127 private $_minorGridlines = null;
128
129 /**
130 * Top-Left Cell Position
131 *
132 * @var string
133 */
134 private $_topLeftCellRef = 'A1';
135
136
137 /**
138 * Top-Left X-Offset
139 *
140 * @var integer
141 */
142 private $_topLeftXOffset = 0;
143
144
145 /**
146 * Top-Left Y-Offset
147 *
148 * @var integer
149 */
150 private $_topLeftYOffset = 0;
151
152
153 /**
154 * Bottom-Right Cell Position
155 *
156 * @var string
157 */
158 private $_bottomRightCellRef = 'A1';
159
160
161 /**
162 * Bottom-Right X-Offset
163 *
164 * @var integer
165 */
166 private $_bottomRightXOffset = 10;
167
168
169 /**
170 * Bottom-Right Y-Offset
171 *
172 * @var integer
173 */
174 private $_bottomRightYOffset = 10;
175
176
177 /**
178 * Create a new PHPExcel_Chart
179 */
180 public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null)
181 {
182 $this->_name = $name;
183 $this->_title = $title;
184 $this->_legend = $legend;
185 $this->_xAxisLabel = $xAxisLabel;
186 $this->_yAxisLabel = $yAxisLabel;
187 $this->_plotArea = $plotArea;
188 $this->_plotVisibleOnly = $plotVisibleOnly;
189 $this->_displayBlanksAs = $displayBlanksAs;
190 $this->_xAxis = $xAxis;
191 $this->_yAxis = $yAxis;
192 $this->_majorGridlines = $majorGridlines;
193 $this->_minorGridlines = $minorGridlines;
194 }
195
196 /**
197 * Get Name
198 *
199 * @return string
200 */
201 public function getName() {
202 return $this->_name;
203 }
204
205 /**
206 * Get Worksheet
207 *
208 * @return PHPExcel_Worksheet
209 */
210 public function getWorksheet() {
211 return $this->_worksheet;
212 }
213
214 /**
215 * Set Worksheet
216 *
217 * @param PHPExcel_Worksheet $pValue
218 * @throws PHPExcel_Chart_Exception
219 * @return PHPExcel_Chart
220 */
221 public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
222 $this->_worksheet = $pValue;
223
224 return $this;
225 }
226
227 /**
228 * Get Title
229 *
230 * @return PHPExcel_Chart_Title
231 */
232 public function getTitle() {
233 return $this->_title;
234 }
235
236 /**
237 * Set Title
238 *
239 * @param PHPExcel_Chart_Title $title
240 * @return PHPExcel_Chart
241 */
242 public function setTitle(PHPExcel_Chart_Title $title) {
243 $this->_title = $title;
244
245 return $this;
246 }
247
248 /**
249 * Get Legend
250 *
251 * @return PHPExcel_Chart_Legend
252 */
253 public function getLegend() {
254 return $this->_legend;
255 }
256
257 /**
258 * Set Legend
259 *
260 * @param PHPExcel_Chart_Legend $legend
261 * @return PHPExcel_Chart
262 */
263 public function setLegend(PHPExcel_Chart_Legend $legend) {
264 $this->_legend = $legend;
265
266 return $this;
267 }
268
269 /**
270 * Get X-Axis Label
271 *
272 * @return PHPExcel_Chart_Title
273 */
274 public function getXAxisLabel() {
275 return $this->_xAxisLabel;
276 }
277
278 /**
279 * Set X-Axis Label
280 *
281 * @param PHPExcel_Chart_Title $label
282 * @return PHPExcel_Chart
283 */
284 public function setXAxisLabel(PHPExcel_Chart_Title $label) {
285 $this->_xAxisLabel = $label;
286
287 return $this;
288 }
289
290 /**
291 * Get Y-Axis Label
292 *
293 * @return PHPExcel_Chart_Title
294 */
295 public function getYAxisLabel() {
296 return $this->_yAxisLabel;
297 }
298
299 /**
300 * Set Y-Axis Label
301 *
302 * @param PHPExcel_Chart_Title $label
303 * @return PHPExcel_Chart
304 */
305 public function setYAxisLabel(PHPExcel_Chart_Title $label) {
306 $this->_yAxisLabel = $label;
307
308 return $this;
309 }
310
311 /**
312 * Get Plot Area
313 *
314 * @return PHPExcel_Chart_PlotArea
315 */
316 public function getPlotArea() {
317 return $this->_plotArea;
318 }
319
320 /**
321 * Get Plot Visible Only
322 *
323 * @return boolean
324 */
325 public function getPlotVisibleOnly() {
326 return $this->_plotVisibleOnly;
327 }
328
329 /**
330 * Set Plot Visible Only
331 *
332 * @param boolean $plotVisibleOnly
333 * @return PHPExcel_Chart
334 */
335 public function setPlotVisibleOnly($plotVisibleOnly = true) {
336 $this->_plotVisibleOnly = $plotVisibleOnly;
337
338 return $this;
339 }
340
341 /**
342 * Get Display Blanks as
343 *
344 * @return string
345 */
346 public function getDisplayBlanksAs() {
347 return $this->_displayBlanksAs;
348 }
349
350 /**
351 * Set Display Blanks as
352 *
353 * @param string $displayBlanksAs
354 * @return PHPExcel_Chart
355 */
356 public function setDisplayBlanksAs($displayBlanksAs = '0') {
357 $this->_displayBlanksAs = $displayBlanksAs;
358 }
359
360
361 /**
362 * Get yAxis
363 *
364 * @return PHPExcel_Chart_Axis
365 */
366 public function getChartAxisY() {
367 if($this->_yAxis !== NULL){
368 return $this->_yAxis;
369 }
370
371 return new PHPExcel_Chart_Axis();
372 }
373
374 /**
375 * Get xAxis
376 *
377 * @return PHPExcel_Chart_Axis
378 */
379 public function getChartAxisX() {
380 if($this->_xAxis !== NULL){
381 return $this->_xAxis;
382 }
383
384 return new PHPExcel_Chart_Axis();
385 }
386
387 /**
388 * Get Major Gridlines
389 *
390 * @return PHPExcel_Chart_GridLines
391 */
392 public function getMajorGridlines() {
393 if($this->_majorGridlines !== NULL){
394 return $this->_majorGridlines;
395 }
396
397 return new PHPExcel_Chart_GridLines();
398 }
399
400 /**
401 * Get Minor Gridlines
402 *
403 * @return PHPExcel_Chart_GridLines
404 */
405 public function getMinorGridlines() {
406 if($this->_minorGridlines !== NULL){
407 return $this->_minorGridlines;
408 }
409
410 return new PHPExcel_Chart_GridLines();
411 }
412
413
414 /**
415 * Set the Top Left position for the chart
416 *
417 * @param string $cell
418 * @param integer $xOffset
419 * @param integer $yOffset
420 * @return PHPExcel_Chart
421 */
422 public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
423 $this->_topLeftCellRef = $cell;
424 if (!is_null($xOffset))
425 $this->setTopLeftXOffset($xOffset);
426 if (!is_null($yOffset))
427 $this->setTopLeftYOffset($yOffset);
428
429 return $this;
430 }
431
432 /**
433 * Get the top left position of the chart
434 *
435 * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
436 */
437 public function getTopLeftPosition() {
438 return array( 'cell' => $this->_topLeftCellRef,
439 'xOffset' => $this->_topLeftXOffset,
440 'yOffset' => $this->_topLeftYOffset
441 );
442 }
443
444 /**
445 * Get the cell address where the top left of the chart is fixed
446 *
447 * @return string
448 */
449 public function getTopLeftCell() {
450 return $this->_topLeftCellRef;
451 }
452
453 /**
454 * Set the Top Left cell position for the chart
455 *
456 * @param string $cell
457 * @return PHPExcel_Chart
458 */
459 public function setTopLeftCell($cell) {
460 $this->_topLeftCellRef = $cell;
461
462 return $this;
463 }
464
465 /**
466 * Set the offset position within the Top Left cell for the chart
467 *
468 * @param integer $xOffset
469 * @param integer $yOffset
470 * @return PHPExcel_Chart
471 */
472 public function setTopLeftOffset($xOffset=null,$yOffset=null) {
473 if (!is_null($xOffset))
474 $this->setTopLeftXOffset($xOffset);
475 if (!is_null($yOffset))
476 $this->setTopLeftYOffset($yOffset);
477
478 return $this;
479 }
480
481 /**
482 * Get the offset position within the Top Left cell for the chart
483 *
484 * @return integer[]
485 */
486 public function getTopLeftOffset() {
487 return array( 'X' => $this->_topLeftXOffset,
488 'Y' => $this->_topLeftYOffset
489 );
490 }
491
492 public function setTopLeftXOffset($xOffset) {
493 $this->_topLeftXOffset = $xOffset;
494
495 return $this;
496 }
497
498 public function getTopLeftXOffset() {
499 return $this->_topLeftXOffset;
500 }
501
502 public function setTopLeftYOffset($yOffset) {
503 $this->_topLeftYOffset = $yOffset;
504
505 return $this;
506 }
507
508 public function getTopLeftYOffset() {
509 return $this->_topLeftYOffset;
510 }
511
512 /**
513 * Set the Bottom Right position of the chart
514 *
515 * @param string $cell
516 * @param integer $xOffset
517 * @param integer $yOffset
518 * @return PHPExcel_Chart
519 */
520 public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
521 $this->_bottomRightCellRef = $cell;
522 if (!is_null($xOffset))
523 $this->setBottomRightXOffset($xOffset);
524 if (!is_null($yOffset))
525 $this->setBottomRightYOffset($yOffset);
526
527 return $this;
528 }
529
530 /**
531 * Get the bottom right position of the chart
532 *
533 * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
534 */
535 public function getBottomRightPosition() {
536 return array( 'cell' => $this->_bottomRightCellRef,
537 'xOffset' => $this->_bottomRightXOffset,
538 'yOffset' => $this->_bottomRightYOffset
539 );
540 }
541
542 public function setBottomRightCell($cell) {
543 $this->_bottomRightCellRef = $cell;
544
545 return $this;
546 }
547
548 /**
549 * Get the cell address where the bottom right of the chart is fixed
550 *
551 * @return string
552 */
553 public function getBottomRightCell() {
554 return $this->_bottomRightCellRef;
555 }
556
557 /**
558 * Set the offset position within the Bottom Right cell for the chart
559 *
560 * @param integer $xOffset
561 * @param integer $yOffset
562 * @return PHPExcel_Chart
563 */
564 public function setBottomRightOffset($xOffset=null,$yOffset=null) {
565 if (!is_null($xOffset))
566 $this->setBottomRightXOffset($xOffset);
567 if (!is_null($yOffset))
568 $this->setBottomRightYOffset($yOffset);
569
570 return $this;
571 }
572
573 /**
574 * Get the offset position within the Bottom Right cell for the chart
575 *
576 * @return integer[]
577 */
578 public function getBottomRightOffset() {
579 return array( 'X' => $this->_bottomRightXOffset,
580 'Y' => $this->_bottomRightYOffset
581 );
582 }
583
584 public function setBottomRightXOffset($xOffset) {
585 $this->_bottomRightXOffset = $xOffset;
586
587 return $this;
588 }
589
590 public function getBottomRightXOffset() {
591 return $this->_bottomRightXOffset;
592 }
593
594 public function setBottomRightYOffset($yOffset) {
595 $this->_bottomRightYOffset = $yOffset;
596
597 return $this;
598 }
599
600 public function getBottomRightYOffset() {
601 return $this->_bottomRightYOffset;
602 }
603
604
605 public function refresh() {
606 if ($this->_worksheet !== NULL) {
607 $this->_plotArea->refresh($this->_worksheet);
608 }
609 }
610
611 public function render($outputDestination = null) {
612 $libraryName = PHPExcel_Settings::getChartRendererName();
613 if (is_null($libraryName)) {
614 return false;
615 }
616 // Ensure that data series values are up-to-date before we render
617 $this->refresh();
618
619 $libraryPath = PHPExcel_Settings::getChartRendererPath();
620 $includePath = str_replace('\\','/',get_include_path());
621 $rendererPath = str_replace('\\','/',$libraryPath);
622 if (strpos($rendererPath,$includePath) === false) {
623 set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
624 }
625
626 $rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
627 $renderer = new $rendererName($this);
628
629 if ($outputDestination == 'php://output') {
630 $outputDestination = null;
631 }
632 return $renderer->render($outputDestination);
633 }
634
635 }
636