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