ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Chart.php
Go to the documentation of this file.
1<?php
2
4
7
8class Chart
9{
15 private $name = '';
16
22 private $worksheet;
23
29 private $title;
30
36 private $legend;
37
43 private $xAxisLabel;
44
50 private $yAxisLabel;
51
57 private $plotArea;
58
64 private $plotVisibleOnly = true;
65
72
78 private $yAxis;
79
85 private $xAxis;
86
93
100
106 private $topLeftCellRef = 'A1';
107
113 private $topLeftXOffset = 0;
114
120 private $topLeftYOffset = 0;
121
127 private $bottomRightCellRef = 'A1';
128
135
142
151 {
152 $this->name = $name;
153 $this->title = $title;
154 $this->legend = $legend;
155 $this->xAxisLabel = $xAxisLabel;
156 $this->yAxisLabel = $yAxisLabel;
157 $this->plotArea = $plotArea;
158 $this->plotVisibleOnly = $plotVisibleOnly;
159 $this->displayBlanksAs = $displayBlanksAs;
160 $this->xAxis = $xAxis;
161 $this->yAxis = $yAxis;
162 $this->majorGridlines = $majorGridlines;
163 $this->minorGridlines = $minorGridlines;
164 }
165
171 public function getName()
172 {
173 return $this->name;
174 }
175
181 public function getWorksheet()
182 {
183 return $this->worksheet;
184 }
185
193 public function setWorksheet(?Worksheet $pValue = null)
194 {
195 $this->worksheet = $pValue;
196
197 return $this;
198 }
199
205 public function getTitle()
206 {
207 return $this->title;
208 }
209
215 public function setTitle(Title $title)
216 {
217 $this->title = $title;
218
219 return $this;
220 }
221
227 public function getLegend()
228 {
229 return $this->legend;
230 }
231
237 public function setLegend(Legend $legend)
238 {
239 $this->legend = $legend;
240
241 return $this;
242 }
243
249 public function getXAxisLabel()
250 {
251 return $this->xAxisLabel;
252 }
253
259 public function setXAxisLabel(Title $label)
260 {
261 $this->xAxisLabel = $label;
262
263 return $this;
264 }
265
271 public function getYAxisLabel()
272 {
273 return $this->yAxisLabel;
274 }
275
281 public function setYAxisLabel(Title $label)
282 {
283 $this->yAxisLabel = $label;
284
285 return $this;
286 }
287
293 public function getPlotArea()
294 {
295 return $this->plotArea;
296 }
297
303 public function getPlotVisibleOnly()
304 {
306 }
307
316 {
317 $this->plotVisibleOnly = $plotVisibleOnly;
318
319 return $this;
320 }
321
327 public function getDisplayBlanksAs()
328 {
330 }
331
340 {
341 $this->displayBlanksAs = $displayBlanksAs;
342
343 return $this;
344 }
345
351 public function getChartAxisY()
352 {
353 if ($this->yAxis !== null) {
354 return $this->yAxis;
355 }
356
357 return new Axis();
358 }
359
365 public function getChartAxisX()
366 {
367 if ($this->xAxis !== null) {
368 return $this->xAxis;
369 }
370
371 return new Axis();
372 }
373
379 public function getMajorGridlines()
380 {
381 if ($this->majorGridlines !== null) {
383 }
384
385 return new GridLines();
386 }
387
393 public function getMinorGridlines()
394 {
395 if ($this->minorGridlines !== null) {
397 }
398
399 return new GridLines();
400 }
401
411 public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
412 {
413 $this->topLeftCellRef = $cell;
414 if ($xOffset !== null) {
415 $this->setTopLeftXOffset($xOffset);
416 }
417 if ($yOffset !== null) {
418 $this->setTopLeftYOffset($yOffset);
419 }
420
421 return $this;
422 }
423
429 public function getTopLeftPosition()
430 {
431 return [
432 'cell' => $this->topLeftCellRef,
433 'xOffset' => $this->topLeftXOffset,
434 'yOffset' => $this->topLeftYOffset,
435 ];
436 }
437
443 public function getTopLeftCell()
444 {
446 }
447
455 public function setTopLeftCell($cell)
456 {
457 $this->topLeftCellRef = $cell;
458
459 return $this;
460 }
461
470 public function setTopLeftOffset($xOffset, $yOffset)
471 {
472 if ($xOffset !== null) {
473 $this->setTopLeftXOffset($xOffset);
474 }
475
476 if ($yOffset !== null) {
477 $this->setTopLeftYOffset($yOffset);
478 }
479
480 return $this;
481 }
482
488 public function getTopLeftOffset()
489 {
490 return [
493 ];
494 }
495
496 public function setTopLeftXOffset($xOffset)
497 {
498 $this->topLeftXOffset = $xOffset;
499
500 return $this;
501 }
502
503 public function getTopLeftXOffset()
504 {
506 }
507
508 public function setTopLeftYOffset($yOffset)
509 {
510 $this->topLeftYOffset = $yOffset;
511
512 return $this;
513 }
514
515 public function getTopLeftYOffset()
516 {
518 }
519
529 public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
530 {
531 $this->bottomRightCellRef = $cell;
532 if ($xOffset !== null) {
533 $this->setBottomRightXOffset($xOffset);
534 }
535 if ($yOffset !== null) {
536 $this->setBottomRightYOffset($yOffset);
537 }
538
539 return $this;
540 }
541
547 public function getBottomRightPosition()
548 {
549 return [
551 'xOffset' => $this->bottomRightXOffset,
552 'yOffset' => $this->bottomRightYOffset,
553 ];
554 }
555
556 public function setBottomRightCell($cell)
557 {
558 $this->bottomRightCellRef = $cell;
559
560 return $this;
561 }
562
568 public function getBottomRightCell()
569 {
571 }
572
581 public function setBottomRightOffset($xOffset, $yOffset)
582 {
583 if ($xOffset !== null) {
584 $this->setBottomRightXOffset($xOffset);
585 }
586
587 if ($yOffset !== null) {
588 $this->setBottomRightYOffset($yOffset);
589 }
590
591 return $this;
592 }
593
599 public function getBottomRightOffset()
600 {
601 return [
604 ];
605 }
606
607 public function setBottomRightXOffset($xOffset)
608 {
609 $this->bottomRightXOffset = $xOffset;
610
611 return $this;
612 }
613
614 public function getBottomRightXOffset()
615 {
617 }
618
619 public function setBottomRightYOffset($yOffset)
620 {
621 $this->bottomRightYOffset = $yOffset;
622
623 return $this;
624 }
625
626 public function getBottomRightYOffset()
627 {
629 }
630
631 public function refresh(): void
632 {
633 if ($this->worksheet !== null) {
634 $this->plotArea->refresh($this->worksheet);
635 }
636 }
637
645 public function render($outputDestination = null)
646 {
647 if ($outputDestination == 'php://output') {
648 $outputDestination = null;
649 }
650
651 $libraryName = Settings::getChartRenderer();
652 if ($libraryName === null) {
653 return false;
654 }
655
656 // Ensure that data series values are up-to-date before we render
657 $this->refresh();
658
659 $renderer = new $libraryName($this);
660
661 return $renderer->render($outputDestination);
662 }
663}
An exception for terminatinating execution or to throw for unit testing.
Created by PhpStorm.
Definition: Axis.php:12
setTopLeftOffset($xOffset, $yOffset)
Set the offset position within the Top Left cell for the chart.
Definition: Chart.php:470
setWorksheet(?Worksheet $pValue=null)
Set Worksheet.
Definition: Chart.php:193
getBottomRightPosition()
Get the bottom right position of the chart.
Definition: Chart.php:547
getTopLeftOffset()
Get the offset position within the Top Left cell for the chart.
Definition: Chart.php:488
setDisplayBlanksAs($displayBlanksAs)
Set Display Blanks as.
Definition: Chart.php:339
setTitle(Title $title)
Set Title.
Definition: Chart.php:215
getTopLeftCell()
Get the cell address where the top left of the chart is fixed.
Definition: Chart.php:443
getBottomRightCell()
Get the cell address where the bottom right of the chart is fixed.
Definition: Chart.php:568
getXAxisLabel()
Get X-Axis Label.
Definition: Chart.php:249
getMinorGridlines()
Get Minor Gridlines.
Definition: Chart.php:393
getMajorGridlines()
Get Major Gridlines.
Definition: Chart.php:379
setTopLeftCell($cell)
Set the Top Left cell position for the chart.
Definition: Chart.php:455
getDisplayBlanksAs()
Get Display Blanks as.
Definition: Chart.php:327
setYAxisLabel(Title $label)
Set Y-Axis Label.
Definition: Chart.php:281
setBottomRightOffset($xOffset, $yOffset)
Set the offset position within the Bottom Right cell for the chart.
Definition: Chart.php:581
setPlotVisibleOnly($plotVisibleOnly)
Set Plot Visible Only.
Definition: Chart.php:315
setBottomRightPosition($cell, $xOffset=null, $yOffset=null)
Set the Bottom Right position of the chart.
Definition: Chart.php:529
getPlotVisibleOnly()
Get Plot Visible Only.
Definition: Chart.php:303
getBottomRightOffset()
Get the offset position within the Bottom Right cell for the chart.
Definition: Chart.php:599
getTopLeftPosition()
Get the top left position of the chart.
Definition: Chart.php:429
getYAxisLabel()
Get Y-Axis Label.
Definition: Chart.php:271
render($outputDestination=null)
Render the chart to given file (or stream).
Definition: Chart.php:645
setXAxisLabel(Title $label)
Set X-Axis Label.
Definition: Chart.php:259
__construct($name, ?Title $title=null, ?Legend $legend=null, ?PlotArea $plotArea=null, $plotVisibleOnly=true, $displayBlanksAs=DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel=null, ?Title $yAxisLabel=null, ?Axis $xAxis=null, ?Axis $yAxis=null, ?GridLines $majorGridlines=null, ?GridLines $minorGridlines=null)
Create a new Chart.
Definition: Chart.php:150
setLegend(Legend $legend)
Set Legend.
Definition: Chart.php:237
setTopLeftPosition($cell, $xOffset=null, $yOffset=null)
Set the Top Left position for the chart.
Definition: Chart.php:411
static getChartRenderer()
Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use.
Definition: Settings.php:92