PlotArea.php 2.0 KB

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