Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Chart;
   4  
   5  use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
   6  
   7  class PlotArea
   8  {
   9      /**
  10       * PlotArea Layout.
  11       *
  12       * @var Layout
  13       */
  14      private $layout;
  15  
  16      /**
  17       * Plot Series.
  18       *
  19       * @var DataSeries[]
  20       */
  21      private $plotSeries = [];
  22  
  23      /**
  24       * Create a new PlotArea.
  25       *
  26       * @param DataSeries[] $plotSeries
  27       */
  28      public function __construct(?Layout $layout = null, array $plotSeries = [])
  29      {
  30          $this->layout = $layout;
  31          $this->plotSeries = $plotSeries;
  32      }
  33  
  34      /**
  35       * Get Layout.
  36       *
  37       * @return Layout
  38       */
  39      public function getLayout()
  40      {
  41          return $this->layout;
  42      }
  43  
  44      /**
  45       * Get Number of Plot Groups.
  46       */
  47      public function getPlotGroupCount(): int
  48      {
  49          return count($this->plotSeries);
  50      }
  51  
  52      /**
  53       * Get Number of Plot Series.
  54       *
  55       * @return int
  56       */
  57      public function getPlotSeriesCount()
  58      {
  59          $seriesCount = 0;
  60          foreach ($this->plotSeries as $plot) {
  61              $seriesCount += $plot->getPlotSeriesCount();
  62          }
  63  
  64          return $seriesCount;
  65      }
  66  
  67      /**
  68       * Get Plot Series.
  69       *
  70       * @return DataSeries[]
  71       */
  72      public function getPlotGroup()
  73      {
  74          return $this->plotSeries;
  75      }
  76  
  77      /**
  78       * Get Plot Series by Index.
  79       *
  80       * @param mixed $index
  81       *
  82       * @return DataSeries
  83       */
  84      public function getPlotGroupByIndex($index)
  85      {
  86          return $this->plotSeries[$index];
  87      }
  88  
  89      /**
  90       * Set Plot Series.
  91       *
  92       * @param DataSeries[] $plotSeries
  93       *
  94       * @return $this
  95       */
  96      public function setPlotSeries(array $plotSeries)
  97      {
  98          $this->plotSeries = $plotSeries;
  99  
 100          return $this;
 101      }
 102  
 103      public function refresh(Worksheet $worksheet): void
 104      {
 105          foreach ($this->plotSeries as $plotSeries) {
 106              $plotSeries->refresh($worksheet);
 107          }
 108      }
 109  }