ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Data\Chart\Dataset Class Reference
+ Collaboration diagram for ILIAS\Data\Chart\Dataset:

Public Member Functions

 __construct (array $dimensions, array $dimension_groups=[])
 
 getDimensions ()
 
 getDimensionGroups ()
 
 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 $dimension_groups = []
 
array $points = []
 
array $alternative_information = []
 

Detailed Description

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

Definition at line 28 of file Dataset.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 39 of file Dataset.php.

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

40  {
41  foreach ($dimensions as $name => $dimension) {
42  if (!is_string($name)) {
43  throw new \InvalidArgumentException(
44  "Expected array key to be a string, '$name' is given."
45  );
46  }
47  if (!$dimension instanceof Dimension\Dimension) {
48  throw new \InvalidArgumentException(
49  "Expected array value to be an instance of Dimension." .
50  (is_object($dimension) ? get_class($dimension) : gettype($dimension)) . " is given."
51  );
52  }
53  }
54  $this->dimensions = $dimensions;
55 
56  foreach ($dimension_groups as $group_name => $group) {
57  if (!is_string($group_name)) {
58  throw new \InvalidArgumentException(
59  "Expected array key to be a string, '$group_name' is given."
60  );
61  }
62  if (!$group instanceof Dimension\DimensionGroup) {
63  throw new \InvalidArgumentException(
64  "Expected array value to be an instance of DimensionGroup. " .
65  (is_object($group) ? get_class($group) : gettype($group)) . " is given."
66  );
67  }
68  }
69  $this->dimension_groups = $dimension_groups;
70  }

Member Function Documentation

◆ checkDimensionCongruenceForValues()

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

Definition at line 88 of file Dataset.php.

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

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

88  : void
89  {
90  if (array_diff_key($values, $this->getDimensions())
91  || array_diff_key($this->getDimensions(), $values)
92  ) {
93  throw new \ArgumentCountError(
94  "The number of the passed values does not match with the number of Dimensions."
95  );
96  }
97  }
+ 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 159 of file Dataset.php.

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

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

159  : array
160  {
162  }
array $alternative_information
Definition: Dataset.php:33
+ Here is the caller graph for this function:

◆ getAlternativeInformationPerDimension()

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

Definition at line 164 of file Dataset.php.

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

164  : array
165  {
166  $alternative_information_restructured = [];
167  foreach ($this->getAlternativeInformation() as $measurement_item_label => $alternative_information_for_dimensions) {
168  foreach ($alternative_information_for_dimensions as $dimension_name => $alternative_info) {
169  $alternative_information_restructured[$dimension_name][$measurement_item_label] = $alternative_info;
170  }
171  }
172 
173  return $alternative_information_restructured;
174  }
+ Here is the call graph for this function:

◆ getDimensionGroups()

ILIAS\Data\Chart\Dataset::getDimensionGroups ( )
Returns
Dimension[]

Definition at line 83 of file Dataset.php.

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

83  : array
84  {
86  }

◆ getDimensions()

ILIAS\Data\Chart\Dataset::getDimensions ( )
Returns
Dimension[]

Definition at line 75 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().

75  : array
76  {
77  return $this->dimensions;
78  }
+ Here is the caller graph for this function:

◆ getMaxValueForDimension()

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

Definition at line 220 of file Dataset.php.

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

220  : float
221  {
222  if ($this->isEmpty()) {
223  throw new \RuntimeException(
224  "Dataset must not be empty."
225  );
226  }
227 
228  $max = null;
229  $dimension_points = $this->getPointsPerDimension()[$dimension_name];
230  foreach ($dimension_points as $point) {
231  if (is_array($point)) {
232  foreach ($point as $p) {
233  if (is_null($max) || $p > $max) {
234  $max = $p;
235  }
236  }
237  } elseif (is_null($max) || !is_null($point) && $point > $max) {
238  $max = $point;
239  }
240  }
241 
242  return (float) $max;
243  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getMinValueForDimension()

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

Definition at line 195 of file Dataset.php.

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

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

◆ getPoints()

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

Definition at line 119 of file Dataset.php.

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

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

119  : array
120  {
121  return $this->points;
122  }
+ Here is the caller graph for this function:

◆ getPointsPerDimension()

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

Definition at line 124 of file Dataset.php.

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

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

124  : array
125  {
126  $points_restructured = [];
127  foreach ($this->getPoints() as $measurement_item_label => $points_for_dimensions) {
128  foreach ($points_for_dimensions as $dimension_name => $point) {
129  $points_restructured[$dimension_name][$measurement_item_label] = $point;
130  }
131  }
132 
133  return $points_restructured;
134  }
+ 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 187 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().

187  : bool
188  {
189  if (empty($this->getPoints())) {
190  return true;
191  }
192  return false;
193  }
+ 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 141 of file Dataset.php.

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

141  : self
142  {
143  $this->checkDimensionCongruenceForValues($values);
144 
145  foreach ($values as $dimension_name => $value) {
146  if (!is_string($value) && !is_null($value)) {
147  throw new \InvalidArgumentException(
148  "Expected array value to be a string or null, '$value' is given."
149  );
150  }
151  }
152 
153  $clone = clone $this;
154  $clone->alternative_information[$measurement_item_label] = $values;
155 
156  return $clone;
157  }
checkDimensionCongruenceForValues(array $values)
Definition: Dataset.php:88
+ 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 104 of file Dataset.php.

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

104  : self
105  {
106  $this->checkDimensionCongruenceForValues($values);
107 
108  foreach ($values as $dimension_name => $value) {
109  $dimension = $this->getDimensions()[$dimension_name];
110  $dimension->checkValue($value);
111  }
112 
113  $clone = clone $this;
114  $clone->points[$measurement_item_label] = $values;
115 
116  return $clone;
117  }
checkDimensionCongruenceForValues(array $values)
Definition: Dataset.php:88
+ Here is the call graph for this function:

◆ withResetDataset()

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

Returns an empty Dataset clone.

Definition at line 179 of file Dataset.php.

179  : self
180  {
181  $clone = clone $this;
182  $clone->points = [];
183  $clone->alternative_information = [];
184  return $clone;
185  }

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().

◆ $dimension_groups

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

◆ $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: