Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Chart;
   4  
   5  use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
   6  
   7  class PlotArea
   8  {
   9      /**
  10       * No fill in plot area (show Excel gridlines through chart).
  11       *
  12       * @var bool
  13       */
  14      private $noFill = false;
  15  
  16      /**
  17       * PlotArea Gradient Stop list.
  18       * Each entry is a 2-element array.
  19       *     First is position in %.
  20       *     Second is ChartColor.
  21       *
  22       * @var array[]
  23       */
  24      private $gradientFillStops = [];
  25  
  26      /**
  27       * PlotArea Gradient Angle.
  28       *
  29       * @var ?float
  30       */
  31      private $gradientFillAngle;
  32  
  33      /**
  34       * PlotArea Layout.
  35       *
  36       * @var ?Layout
  37       */
  38      private $layout;
  39  
  40      /**
  41       * Plot Series.
  42       *
  43       * @var DataSeries[]
  44       */
  45      private $plotSeries = [];
  46  
  47      /**
  48       * Create a new PlotArea.
  49       *
  50       * @param DataSeries[] $plotSeries
  51       */
  52      public function __construct(?Layout $layout = null, array $plotSeries = [])
  53      {
  54          $this->layout = $layout;
  55          $this->plotSeries = $plotSeries;
  56      }
  57  
  58      public function getLayout(): ?Layout
  59      {
  60          return $this->layout;
  61      }
  62  
  63      /**
  64       * Get Number of Plot Groups.
  65       */
  66      public function getPlotGroupCount(): int
  67      {
  68          return count($this->plotSeries);
  69      }
  70  
  71      /**
  72       * Get Number of Plot Series.
  73       *
  74       * @return int
  75       */
  76      public function getPlotSeriesCount()
  77      {
  78          $seriesCount = 0;
  79          foreach ($this->plotSeries as $plot) {
  80              $seriesCount += $plot->getPlotSeriesCount();
  81          }
  82  
  83          return $seriesCount;
  84      }
  85  
  86      /**
  87       * Get Plot Series.
  88       *
  89       * @return DataSeries[]
  90       */
  91      public function getPlotGroup()
  92      {
  93          return $this->plotSeries;
  94      }
  95  
  96      /**
  97       * Get Plot Series by Index.
  98       *
  99       * @param mixed $index
 100       *
 101       * @return DataSeries
 102       */
 103      public function getPlotGroupByIndex($index)
 104      {
 105          return $this->plotSeries[$index];
 106      }
 107  
 108      /**
 109       * Set Plot Series.
 110       *
 111       * @param DataSeries[] $plotSeries
 112       *
 113       * @return $this
 114       */
 115      public function setPlotSeries(array $plotSeries)
 116      {
 117          $this->plotSeries = $plotSeries;
 118  
 119          return $this;
 120      }
 121  
 122      public function refresh(Worksheet $worksheet): void
 123      {
 124          foreach ($this->plotSeries as $plotSeries) {
 125              $plotSeries->refresh($worksheet);
 126          }
 127      }
 128  
 129      public function setNoFill(bool $noFill): self
 130      {
 131          $this->noFill = $noFill;
 132  
 133          return $this;
 134      }
 135  
 136      public function getNoFill(): bool
 137      {
 138          return $this->noFill;
 139      }
 140  
 141      public function setGradientFillProperties(array $gradientFillStops, ?float $gradientFillAngle): self
 142      {
 143          $this->gradientFillStops = $gradientFillStops;
 144          $this->gradientFillAngle = $gradientFillAngle;
 145  
 146          return $this;
 147      }
 148  
 149      /**
 150       * Get gradientFillAngle.
 151       */
 152      public function getGradientFillAngle(): ?float
 153      {
 154          return $this->gradientFillAngle;
 155      }
 156  
 157      /**
 158       * Get gradientFillStops.
 159       *
 160       * @return array
 161       */
 162      public function getGradientFillStops()
 163      {
 164          return $this->gradientFillStops;
 165      }
 166  }