ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Data\Chart\Dataset Class Reference
+ Collaboration diagram for ILIAS\Data\Chart\Dataset:

Public Member Functions

 __construct (array $dimensions)
 
 getDimensions ()
 
 withPoint (string $measurement_item_label, array $values)
 
 getPoints ()
 
 getPointsPerDimension ()
 
 withAlternativeInformation (string $measurement_item_label, array $values)
 
 getAlternativeInformation ()
 
 getAlternativeInformationPerDimension ()
 
 withResetDataset ()
 Returns an empty Dataset clone. More...
 
 isEmpty ()
 
 getMinValueForDimension (string $dimension_name)
 
 getMaxValueForDimension (string $dimension_name)
 

Protected Member Functions

 checkDimensionCongruenceForValues (array $values)
 

Protected Attributes

array $dimensions = []
 
array $points = []
 
array $alternative_information = []
 

Detailed Description

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 29 of file Dataset.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Chart\Dataset::__construct ( array  $dimensions)
Parameters
array<string,Dimension

Definition at line 38 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\$dimensions, and $name.

39  {
40  foreach ($dimensions as $name => $dimension) {
41  if (!is_string($name)) {
42  throw new \InvalidArgumentException(
43  "Expected array key to be a string, '$name' is given."
44  );
45  }
46  if (!$dimension instanceof Dimension\Dimension) {
47  throw new \InvalidArgumentException(
48  "Expected array value to be an instance of Dimension, '$dimension' is given."
49  );
50  }
51  }
52  $this->dimensions = $dimensions;
53  }
if($format !==null) $name
Definition: metadata.php:247

Member Function Documentation

◆ checkDimensionCongruenceForValues()

ILIAS\Data\Chart\Dataset::checkDimensionCongruenceForValues ( array  $values)
protected

Definition at line 60 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getDimensions().

Referenced by ILIAS\Data\Chart\Dataset\withAlternativeInformation(), and ILIAS\Data\Chart\Dataset\withPoint().

60  : void
61  {
62  if (array_diff_key($values, $this->getDimensions())
63  || array_diff_key($this->getDimensions(), $values)
64  ) {
65  throw new \ArgumentCountError(
66  "The number of the passed values does not match with the number of Dimensions."
67  );
68  }
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAlternativeInformation()

ILIAS\Data\Chart\Dataset::getAlternativeInformation ( )

Definition at line 131 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\$alternative_information.

Referenced by ILIAS\Data\Chart\Dataset\getAlternativeInformationPerDimension().

131  : array
132  {
134  }
array $alternative_information
Definition: Dataset.php:33
+ Here is the caller graph for this function:

◆ getAlternativeInformationPerDimension()

ILIAS\Data\Chart\Dataset::getAlternativeInformationPerDimension ( )

Definition at line 136 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getAlternativeInformation().

136  : array
137  {
138  $alternative_information_restructured = [];
139  foreach ($this->getAlternativeInformation() as $measurement_item_label => $alternative_information_for_dimensions) {
140  foreach ($alternative_information_for_dimensions as $dimension_name => $alternative_info) {
141  $alternative_information_restructured[$dimension_name][$measurement_item_label] = $alternative_info;
142  }
143  }
144 
145  return $alternative_information_restructured;
146  }
+ Here is the call graph for this function:

◆ getDimensions()

ILIAS\Data\Chart\Dataset::getDimensions ( )

Definition at line 55 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\$dimensions.

Referenced by ILIAS\UI\Implementation\Component\Chart\Bar\Bar\__construct(), ILIAS\Data\Chart\Dataset\checkDimensionCongruenceForValues(), and ILIAS\Data\Chart\Dataset\withPoint().

55  : array
56  {
57  return $this->dimensions;
58  }
+ Here is the caller graph for this function:

◆ getMaxValueForDimension()

ILIAS\Data\Chart\Dataset::getMaxValueForDimension ( string  $dimension_name)

Definition at line 192 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getPointsPerDimension(), and ILIAS\Data\Chart\Dataset\isEmpty().

192  : float
193  {
194  if ($this->isEmpty()) {
195  throw new \RuntimeException(
196  "Dataset must not be empty."
197  );
198  }
199 
200  $max = null;
201  $dimension_points = $this->getPointsPerDimension()[$dimension_name];
202  foreach ($dimension_points as $point) {
203  if (is_array($point)) {
204  foreach ($point as $p) {
205  if (is_null($max) || $p > $max) {
206  $max = $p;
207  }
208  }
209  } elseif (is_null($max) || !is_null($point) && $point > $max) {
210  $max = $point;
211  }
212  }
213 
214  return (float) $max;
215  }
+ Here is the call graph for this function:

◆ getMinValueForDimension()

ILIAS\Data\Chart\Dataset::getMinValueForDimension ( string  $dimension_name)

Definition at line 167 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getPointsPerDimension(), and ILIAS\Data\Chart\Dataset\isEmpty().

167  : float
168  {
169  if ($this->isEmpty()) {
170  throw new \RuntimeException(
171  "Dataset must not be empty."
172  );
173  }
174 
175  $min = null;
176  $dimension_points = $this->getPointsPerDimension()[$dimension_name];
177  foreach ($dimension_points as $point) {
178  if (is_array($point)) {
179  foreach ($point as $p) {
180  if (is_null($min) || $p < $min) {
181  $min = $p;
182  }
183  }
184  } elseif (is_null($min) || !is_null($point) && $point < $min) {
185  $min = $point;
186  }
187  }
188 
189  return (float) $min;
190  }
+ Here is the call graph for this function:

◆ getPoints()

ILIAS\Data\Chart\Dataset::getPoints ( )

Definition at line 91 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\$points.

Referenced by ILIAS\Data\Chart\Dataset\getPointsPerDimension(), and ILIAS\Data\Chart\Dataset\isEmpty().

91  : array
92  {
93  return $this->points;
94  }
+ Here is the caller graph for this function:

◆ getPointsPerDimension()

ILIAS\Data\Chart\Dataset::getPointsPerDimension ( )

Definition at line 96 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getPoints().

Referenced by ILIAS\Data\Chart\Dataset\getMaxValueForDimension(), and ILIAS\Data\Chart\Dataset\getMinValueForDimension().

96  : array
97  {
98  $points_restructured = [];
99  foreach ($this->getPoints() as $measurement_item_label => $points_for_dimensions) {
100  foreach ($points_for_dimensions as $dimension_name => $point) {
101  $points_restructured[$dimension_name][$measurement_item_label] = $point;
102  }
103  }
104 
105  return $points_restructured;
106  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmpty()

ILIAS\Data\Chart\Dataset::isEmpty ( )

Definition at line 159 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\getPoints().

Referenced by ILIAS\UI\Implementation\Component\Chart\Bar\Bar\__construct(), ILIAS\Data\Chart\Dataset\getMaxValueForDimension(), and ILIAS\Data\Chart\Dataset\getMinValueForDimension().

159  : bool
160  {
161  if (empty($this->getPoints())) {
162  return true;
163  }
164  return false;
165  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withAlternativeInformation()

ILIAS\Data\Chart\Dataset::withAlternativeInformation ( string  $measurement_item_label,
array  $values 
)
Parameters
string$measurement_item_label
array<string,string>$values key: Dimension name, value: Alternative text as string value or null
Returns
$this

Definition at line 113 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\checkDimensionCongruenceForValues().

113  : self
114  {
115  $this->checkDimensionCongruenceForValues($values);
116 
117  foreach ($values as $dimension_name => $value) {
118  if (!is_string($value) && !is_null($value)) {
119  throw new \InvalidArgumentException(
120  "Expected array value to be a string or null, '$value' is given."
121  );
122  }
123  }
124 
125  $clone = clone $this;
126  $clone->alternative_information[$measurement_item_label] = $values;
127 
128  return $clone;
129  }
checkDimensionCongruenceForValues(array $values)
Definition: Dataset.php:60
+ Here is the call graph for this function:

◆ withPoint()

ILIAS\Data\Chart\Dataset::withPoint ( string  $measurement_item_label,
array  $values 
)
Parameters
string$measurement_item_labelUsing the identical label multiple times will overwrite the values
array<string,mixed>$values key: Dimension name, value: mixed (validity depends on the dimension)
Returns
$this

Definition at line 76 of file Dataset.php.

References ILIAS\Data\Chart\Dataset\checkDimensionCongruenceForValues(), and ILIAS\Data\Chart\Dataset\getDimensions().

76  : self
77  {
78  $this->checkDimensionCongruenceForValues($values);
79 
80  foreach ($values as $dimension_name => $value) {
81  $dimension = $this->getDimensions()[$dimension_name];
82  $dimension->checkValue($value);
83  }
84 
85  $clone = clone $this;
86  $clone->points[$measurement_item_label] = $values;
87 
88  return $clone;
89  }
checkDimensionCongruenceForValues(array $values)
Definition: Dataset.php:60
+ Here is the call graph for this function:

◆ withResetDataset()

ILIAS\Data\Chart\Dataset::withResetDataset ( )

Returns an empty Dataset clone.

Definition at line 151 of file Dataset.php.

151  : self
152  {
153  $clone = clone $this;
154  $clone->points = [];
155  $clone->alternative_information = [];
156  return $clone;
157  }

Field Documentation

◆ $alternative_information

array ILIAS\Data\Chart\Dataset::$alternative_information = []
protected

Definition at line 33 of file Dataset.php.

Referenced by ILIAS\Data\Chart\Dataset\getAlternativeInformation().

◆ $dimensions

array ILIAS\Data\Chart\Dataset::$dimensions = []
protected

◆ $points

array ILIAS\Data\Chart\Dataset::$points = []
protected

Definition at line 32 of file Dataset.php.

Referenced by ILIAS\Data\Chart\Dataset\getPoints().


The documentation for this class was generated from the following file: