Updated gui for user facility settings (#1327)
[openemr.git] / vendor / phpoffice / phpexcel / Classes / PHPExcel / Chart.php
blob9bf72dbbd4ffd182d6d3d504b661d9894a61b187
1 <?php
2 /**
3 * PHPExcel
5 * Copyright (c) 2006 - 2014 PHPExcel
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.
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.
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
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##
29 /**
30 * PHPExcel_Chart
32 * @category PHPExcel
33 * @package PHPExcel_Chart
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
36 class PHPExcel_Chart
38 /**
39 * Chart Name
41 * @var string
43 private $_name = '';
45 /**
46 * Worksheet
48 * @var PHPExcel_Worksheet
50 private $_worksheet = null;
52 /**
53 * Chart Title
55 * @var PHPExcel_Chart_Title
57 private $_title = null;
59 /**
60 * Chart Legend
62 * @var PHPExcel_Chart_Legend
64 private $_legend = null;
66 /**
67 * X-Axis Label
69 * @var PHPExcel_Chart_Title
71 private $_xAxisLabel = null;
73 /**
74 * Y-Axis Label
76 * @var PHPExcel_Chart_Title
78 private $_yAxisLabel = null;
80 /**
81 * Chart Plot Area
83 * @var PHPExcel_Chart_PlotArea
85 private $_plotArea = null;
87 /**
88 * Plot Visible Only
90 * @var boolean
92 private $_plotVisibleOnly = true;
94 /**
95 * Display Blanks as
97 * @var string
99 private $_displayBlanksAs = '0';
102 * Chart Asix Y as
104 * @var PHPExcel_Chart_Axis
106 private $_yAxis = null;
109 * Chart Asix X as
111 * @var PHPExcel_Chart_Axis
113 private $_xAxis = null;
116 * Chart Major Gridlines as
118 * @var PHPExcel_Chart_GridLines
120 private $_majorGridlines = null;
123 * Chart Minor Gridlines as
125 * @var PHPExcel_Chart_GridLines
127 private $_minorGridlines = null;
130 * Top-Left Cell Position
132 * @var string
134 private $_topLeftCellRef = 'A1';
138 * Top-Left X-Offset
140 * @var integer
142 private $_topLeftXOffset = 0;
146 * Top-Left Y-Offset
148 * @var integer
150 private $_topLeftYOffset = 0;
154 * Bottom-Right Cell Position
156 * @var string
158 private $_bottomRightCellRef = 'A1';
162 * Bottom-Right X-Offset
164 * @var integer
166 private $_bottomRightXOffset = 10;
170 * Bottom-Right Y-Offset
172 * @var integer
174 private $_bottomRightYOffset = 10;
178 * Create a new PHPExcel_Chart
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)
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;
197 * Get Name
199 * @return string
201 public function getName() {
202 return $this->_name;
206 * Get Worksheet
208 * @return PHPExcel_Worksheet
210 public function getWorksheet() {
211 return $this->_worksheet;
215 * Set Worksheet
217 * @param PHPExcel_Worksheet $pValue
218 * @throws PHPExcel_Chart_Exception
219 * @return PHPExcel_Chart
221 public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
222 $this->_worksheet = $pValue;
224 return $this;
228 * Get Title
230 * @return PHPExcel_Chart_Title
232 public function getTitle() {
233 return $this->_title;
237 * Set Title
239 * @param PHPExcel_Chart_Title $title
240 * @return PHPExcel_Chart
242 public function setTitle(PHPExcel_Chart_Title $title) {
243 $this->_title = $title;
245 return $this;
249 * Get Legend
251 * @return PHPExcel_Chart_Legend
253 public function getLegend() {
254 return $this->_legend;
258 * Set Legend
260 * @param PHPExcel_Chart_Legend $legend
261 * @return PHPExcel_Chart
263 public function setLegend(PHPExcel_Chart_Legend $legend) {
264 $this->_legend = $legend;
266 return $this;
270 * Get X-Axis Label
272 * @return PHPExcel_Chart_Title
274 public function getXAxisLabel() {
275 return $this->_xAxisLabel;
279 * Set X-Axis Label
281 * @param PHPExcel_Chart_Title $label
282 * @return PHPExcel_Chart
284 public function setXAxisLabel(PHPExcel_Chart_Title $label) {
285 $this->_xAxisLabel = $label;
287 return $this;
291 * Get Y-Axis Label
293 * @return PHPExcel_Chart_Title
295 public function getYAxisLabel() {
296 return $this->_yAxisLabel;
300 * Set Y-Axis Label
302 * @param PHPExcel_Chart_Title $label
303 * @return PHPExcel_Chart
305 public function setYAxisLabel(PHPExcel_Chart_Title $label) {
306 $this->_yAxisLabel = $label;
308 return $this;
312 * Get Plot Area
314 * @return PHPExcel_Chart_PlotArea
316 public function getPlotArea() {
317 return $this->_plotArea;
321 * Get Plot Visible Only
323 * @return boolean
325 public function getPlotVisibleOnly() {
326 return $this->_plotVisibleOnly;
330 * Set Plot Visible Only
332 * @param boolean $plotVisibleOnly
333 * @return PHPExcel_Chart
335 public function setPlotVisibleOnly($plotVisibleOnly = true) {
336 $this->_plotVisibleOnly = $plotVisibleOnly;
338 return $this;
342 * Get Display Blanks as
344 * @return string
346 public function getDisplayBlanksAs() {
347 return $this->_displayBlanksAs;
351 * Set Display Blanks as
353 * @param string $displayBlanksAs
354 * @return PHPExcel_Chart
356 public function setDisplayBlanksAs($displayBlanksAs = '0') {
357 $this->_displayBlanksAs = $displayBlanksAs;
362 * Get yAxis
364 * @return PHPExcel_Chart_Axis
366 public function getChartAxisY() {
367 if($this->_yAxis !== NULL){
368 return $this->_yAxis;
371 return new PHPExcel_Chart_Axis();
375 * Get xAxis
377 * @return PHPExcel_Chart_Axis
379 public function getChartAxisX() {
380 if($this->_xAxis !== NULL){
381 return $this->_xAxis;
384 return new PHPExcel_Chart_Axis();
388 * Get Major Gridlines
390 * @return PHPExcel_Chart_GridLines
392 public function getMajorGridlines() {
393 if($this->_majorGridlines !== NULL){
394 return $this->_majorGridlines;
397 return new PHPExcel_Chart_GridLines();
401 * Get Minor Gridlines
403 * @return PHPExcel_Chart_GridLines
405 public function getMinorGridlines() {
406 if($this->_minorGridlines !== NULL){
407 return $this->_minorGridlines;
410 return new PHPExcel_Chart_GridLines();
415 * Set the Top Left position for the chart
417 * @param string $cell
418 * @param integer $xOffset
419 * @param integer $yOffset
420 * @return PHPExcel_Chart
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);
429 return $this;
433 * Get the top left position of the chart
435 * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
437 public function getTopLeftPosition() {
438 return array( 'cell' => $this->_topLeftCellRef,
439 'xOffset' => $this->_topLeftXOffset,
440 'yOffset' => $this->_topLeftYOffset
445 * Get the cell address where the top left of the chart is fixed
447 * @return string
449 public function getTopLeftCell() {
450 return $this->_topLeftCellRef;
454 * Set the Top Left cell position for the chart
456 * @param string $cell
457 * @return PHPExcel_Chart
459 public function setTopLeftCell($cell) {
460 $this->_topLeftCellRef = $cell;
462 return $this;
466 * Set the offset position within the Top Left cell for the chart
468 * @param integer $xOffset
469 * @param integer $yOffset
470 * @return PHPExcel_Chart
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);
478 return $this;
482 * Get the offset position within the Top Left cell for the chart
484 * @return integer[]
486 public function getTopLeftOffset() {
487 return array( 'X' => $this->_topLeftXOffset,
488 'Y' => $this->_topLeftYOffset
492 public function setTopLeftXOffset($xOffset) {
493 $this->_topLeftXOffset = $xOffset;
495 return $this;
498 public function getTopLeftXOffset() {
499 return $this->_topLeftXOffset;
502 public function setTopLeftYOffset($yOffset) {
503 $this->_topLeftYOffset = $yOffset;
505 return $this;
508 public function getTopLeftYOffset() {
509 return $this->_topLeftYOffset;
513 * Set the Bottom Right position of the chart
515 * @param string $cell
516 * @param integer $xOffset
517 * @param integer $yOffset
518 * @return PHPExcel_Chart
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);
527 return $this;
531 * Get the bottom right position of the chart
533 * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
535 public function getBottomRightPosition() {
536 return array( 'cell' => $this->_bottomRightCellRef,
537 'xOffset' => $this->_bottomRightXOffset,
538 'yOffset' => $this->_bottomRightYOffset
542 public function setBottomRightCell($cell) {
543 $this->_bottomRightCellRef = $cell;
545 return $this;
549 * Get the cell address where the bottom right of the chart is fixed
551 * @return string
553 public function getBottomRightCell() {
554 return $this->_bottomRightCellRef;
558 * Set the offset position within the Bottom Right cell for the chart
560 * @param integer $xOffset
561 * @param integer $yOffset
562 * @return PHPExcel_Chart
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);
570 return $this;
574 * Get the offset position within the Bottom Right cell for the chart
576 * @return integer[]
578 public function getBottomRightOffset() {
579 return array( 'X' => $this->_bottomRightXOffset,
580 'Y' => $this->_bottomRightYOffset
584 public function setBottomRightXOffset($xOffset) {
585 $this->_bottomRightXOffset = $xOffset;
587 return $this;
590 public function getBottomRightXOffset() {
591 return $this->_bottomRightXOffset;
594 public function setBottomRightYOffset($yOffset) {
595 $this->_bottomRightYOffset = $yOffset;
597 return $this;
600 public function getBottomRightYOffset() {
601 return $this->_bottomRightYOffset;
605 public function refresh() {
606 if ($this->_worksheet !== NULL) {
607 $this->_plotArea->refresh($this->_worksheet);
611 public function render($outputDestination = null) {
612 $libraryName = PHPExcel_Settings::getChartRendererName();
613 if (is_null($libraryName)) {
614 return false;
616 // Ensure that data series values are up-to-date before we render
617 $this->refresh();
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);
626 $rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
627 $renderer = new $rendererName($this);
629 if ($outputDestination == 'php://output') {
630 $outputDestination = null;
632 return $renderer->render($outputDestination);