ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
DataSeries.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 class DataSeries
8 {
9  const TYPE_BARCHART = 'barChart';
10  const TYPE_BARCHART_3D = 'bar3DChart';
11  const TYPE_LINECHART = 'lineChart';
12  const TYPE_LINECHART_3D = 'line3DChart';
13  const TYPE_AREACHART = 'areaChart';
14  const TYPE_AREACHART_3D = 'area3DChart';
15  const TYPE_PIECHART = 'pieChart';
16  const TYPE_PIECHART_3D = 'pie3DChart';
17  const TYPE_DOUGHNUTCHART = 'doughnutChart';
18  const TYPE_DONUTCHART = self::TYPE_DOUGHNUTCHART; // Synonym
19  const TYPE_SCATTERCHART = 'scatterChart';
20  const TYPE_SURFACECHART = 'surfaceChart';
21  const TYPE_SURFACECHART_3D = 'surface3DChart';
22  const TYPE_RADARCHART = 'radarChart';
23  const TYPE_BUBBLECHART = 'bubbleChart';
24  const TYPE_STOCKCHART = 'stockChart';
25  const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
26 
27  const GROUPING_CLUSTERED = 'clustered';
28  const GROUPING_STACKED = 'stacked';
29  const GROUPING_PERCENT_STACKED = 'percentStacked';
30  const GROUPING_STANDARD = 'standard';
31 
32  const DIRECTION_BAR = 'bar';
33  const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
34  const DIRECTION_COL = 'col';
35  const DIRECTION_COLUMN = self::DIRECTION_COL;
36  const DIRECTION_VERTICAL = self::DIRECTION_COL;
37 
38  const STYLE_LINEMARKER = 'lineMarker';
39  const STYLE_SMOOTHMARKER = 'smoothMarker';
40  const STYLE_MARKER = 'marker';
41  const STYLE_FILLED = 'filled';
42 
43  const EMPTY_AS_GAP = 'gap';
44  const EMPTY_AS_ZERO = 'zero';
45  const EMPTY_AS_SPAN = 'span';
46 
52  private $plotType;
53 
59  private $plotGrouping;
60 
66  private $plotDirection;
67 
73  private $plotStyle;
74 
80  private $plotOrder = [];
81 
87  private $plotLabel = [];
88 
94  private $plotCategory = [];
95 
101  private $smoothLine;
102 
108  private $plotValues = [];
109 
123  public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null)
124  {
125  $this->plotType = $plotType;
126  $this->plotGrouping = $plotGrouping;
127  $this->plotOrder = $plotOrder;
128  $keys = array_keys($plotValues);
129  $this->plotValues = $plotValues;
130  if ((count($plotLabel) == 0) || ($plotLabel[$keys[0]] === null)) {
131  $plotLabel[$keys[0]] = new DataSeriesValues();
132  }
133  $this->plotLabel = $plotLabel;
134 
135  if ((count($plotCategory) == 0) || ($plotCategory[$keys[0]] === null)) {
137  }
138  $this->plotCategory = $plotCategory;
139 
140  $this->smoothLine = $smoothLine;
141  $this->plotStyle = $plotStyle;
142 
143  if ($plotDirection === null) {
144  $plotDirection = self::DIRECTION_COL;
145  }
146  $this->plotDirection = $plotDirection;
147  }
148 
154  public function getPlotType()
155  {
156  return $this->plotType;
157  }
158 
166  public function setPlotType($plotType)
167  {
168  $this->plotType = $plotType;
169 
170  return $this;
171  }
172 
178  public function getPlotGrouping()
179  {
180  return $this->plotGrouping;
181  }
182 
190  public function setPlotGrouping($groupingType)
191  {
192  $this->plotGrouping = $groupingType;
193 
194  return $this;
195  }
196 
202  public function getPlotDirection()
203  {
204  return $this->plotDirection;
205  }
206 
215  {
216  $this->plotDirection = $plotDirection;
217 
218  return $this;
219  }
220 
226  public function getPlotOrder()
227  {
228  return $this->plotOrder;
229  }
230 
236  public function getPlotLabels()
237  {
238  return $this->plotLabel;
239  }
240 
248  public function getPlotLabelByIndex($index)
249  {
250  $keys = array_keys($this->plotLabel);
251  if (in_array($index, $keys)) {
252  return $this->plotLabel[$index];
253  } elseif (isset($keys[$index])) {
254  return $this->plotLabel[$keys[$index]];
255  }
256 
257  return false;
258  }
259 
265  public function getPlotCategories()
266  {
267  return $this->plotCategory;
268  }
269 
278  {
279  $keys = array_keys($this->plotCategory);
280  if (in_array($index, $keys)) {
281  return $this->plotCategory[$index];
282  } elseif (isset($keys[$index])) {
283  return $this->plotCategory[$keys[$index]];
284  }
285 
286  return false;
287  }
288 
294  public function getPlotStyle()
295  {
296  return $this->plotStyle;
297  }
298 
306  public function setPlotStyle($plotStyle)
307  {
308  $this->plotStyle = $plotStyle;
309 
310  return $this;
311  }
312 
318  public function getPlotValues()
319  {
320  return $this->plotValues;
321  }
322 
330  public function getPlotValuesByIndex($index)
331  {
332  $keys = array_keys($this->plotValues);
333  if (in_array($index, $keys)) {
334  return $this->plotValues[$index];
335  } elseif (isset($keys[$index])) {
336  return $this->plotValues[$keys[$index]];
337  }
338 
339  return false;
340  }
341 
347  public function getPlotSeriesCount()
348  {
349  return count($this->plotValues);
350  }
351 
357  public function getSmoothLine()
358  {
359  return $this->smoothLine;
360  }
361 
369  public function setSmoothLine($smoothLine)
370  {
371  $this->smoothLine = $smoothLine;
372 
373  return $this;
374  }
375 
376  public function refresh(Worksheet $worksheet): void
377  {
378  foreach ($this->plotValues as $plotValues) {
379  if ($plotValues !== null) {
380  $plotValues->refresh($worksheet, true);
381  }
382  }
383  foreach ($this->plotLabel as $plotValues) {
384  if ($plotValues !== null) {
385  $plotValues->refresh($worksheet, true);
386  }
387  }
388  foreach ($this->plotCategory as $plotValues) {
389  if ($plotValues !== null) {
390  $plotValues->refresh($worksheet, false);
391  }
392  }
393  }
394 }
__construct($plotType=null, $plotGrouping=null, array $plotOrder=[], array $plotLabel=[], array $plotCategory=[], array $plotValues=[], $plotDirection=null, $smoothLine=false, $plotStyle=null)
Create a new DataSeries.
Definition: DataSeries.php:123
getPlotLabelByIndex($index)
Get Plot Label by Index.
Definition: DataSeries.php:248
setSmoothLine($smoothLine)
Set Smooth Line.
Definition: DataSeries.php:369
$index
Definition: metadata.php:60
$keys
getPlotSeriesCount()
Get Number of Plot Series.
Definition: DataSeries.php:347
setPlotGrouping($groupingType)
Set Plot Grouping Type.
Definition: DataSeries.php:190
getPlotCategoryByIndex($index)
Get Plot Category by Index.
Definition: DataSeries.php:277
setPlotType($plotType)
Set Plot Type.
Definition: DataSeries.php:166
getPlotValuesByIndex($index)
Get Plot Values by Index.
Definition: DataSeries.php:330
setPlotDirection($plotDirection)
Set Plot Direction.
Definition: DataSeries.php:214
setPlotStyle($plotStyle)
Set Plot Style.
Definition: DataSeries.php:306
getPlotCategories()
Get Plot Categories.
Definition: DataSeries.php:265
getPlotGrouping()
Get Plot Grouping Type.
Definition: DataSeries.php:178