From 3245609b5b9de90d1fbb13aae516fd59ee1ab62a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 6 Apr 2011 23:51:55 +0200 Subject: [PATCH] some fixes for JpGraph --- htdocs/frontend/images/image.png | Bin 0 -> 516 bytes lib/Interpreter/AggregatorInterpreter.php | 44 ++++++---------------- lib/Interpreter/Interpreter.php | 1 + 3 files changed, 13 insertions(+), 32 deletions(-) create mode 100644 htdocs/frontend/images/image.png diff --git a/htdocs/frontend/images/image.png b/htdocs/frontend/images/image.png new file mode 100644 index 0000000000000000000000000000000000000000..fc3c393caa3bc4371d12d0c67ffd6d333ecf1d8e GIT binary patch literal 516 zcmV+f0{i`mP)0oSgT$J*kO*Aq9I~CW*s{G*(t$KS{OS+#aO%?udUme<*TTEO`Fr@r_QT zk=#}u-n~>Vm!+9S1PE{@3<)G~CPb<$Za;W?3+O}|+q)?*Pn355=}S(XIZmEANjZci zf5 zj<%@MX^bD1^BwlS^+AD|$dm-1wial0hwPI;CDM?Y9SXW#@w-UF0SQ8OgplRTleOB2 zUjkDS|0U9pI|lSN*EvXUa~*UIclJdZ#)Npbwh9>YT?Z;=B8|l&^t~P~om?<5Lre$+ z;%`P>SL7`djY#8Y9$wv9dv|3p)aggregator = $aggregator; - + foreach ($aggregator->getChildren() as $child) { if ($child instanceof Model\Channel) { - if (isset($indicator) && $indicator != $child->getType()) { - throw new \Exception('Can\'t aggregate channels of mixed types!'); - } - else { - $indicator = $child->getType(); - } - - $this->channelInterpreter[] = $child->getInterpreter($em, $from, $to); + $class = $child->getDefinition()->getInterpreter(); + $this->childrenInterpreter[] = new $class($child, $em, $from, $to, $tupleCount, $groupBy); } } } @@ -97,8 +90,8 @@ class AggregatorInterpreter { * @return array with the smallest value */ public function getMin() { - $min = current($this->channelInterpreter)->getMin(); - foreach ($this->channelInterpreter as $interpreter) { + $min = current($this->childrenInterpreter)->getMin(); + foreach ($this->childrenInterpreter as $interpreter) { $arr = $interpreter->getMax(); if ($arr['value '] < $min['value']) { $min = $arr; @@ -113,8 +106,8 @@ class AggregatorInterpreter { * @return array with the biggest value */ public function getMax() { - $max = current($this->channelInterpreter)->getMax(); - foreach ($this->channelInterpreter as $interpreter) { + $max = current($this->childrenInterpreter)->getMax(); + foreach ($this->childrenInterpreter as $interpreter) { $arr = $interpreter->getMax(); if ($arr['value '] > $max['value']) { $max = $arr; @@ -131,24 +124,10 @@ class AggregatorInterpreter { public function getAverage() { $sum = 0; - foreach ($this->channelInterpreter as $interpreter) { + foreach ($this->childrenInterpreter as $interpreter) { $sum += $interpreter->getAverage(); } - return ($sum / count($this->channelInterpreter)); - } - - /** - * Just a passthrough to the channel interpreters - * - * @return float last value - */ - public function getLast() { - $last = 0; - - foreach ($this->channelInterpreter as $interpreter) { - $last = $interpreter->getLast(); - } - return ($last($this->channelInterpreter)); + return ($sum / count($this->childrenInterpreter)); } /* @@ -156,4 +135,5 @@ class AggregatorInterpreter { */ public function getEntity() { return $this->aggregator; } + public function getChildrenInterpreter() { return $this->childrenInterpreter; } } diff --git a/lib/Interpreter/Interpreter.php b/lib/Interpreter/Interpreter.php index 3c33407..18b7c08 100644 --- a/lib/Interpreter/Interpreter.php +++ b/lib/Interpreter/Interpreter.php @@ -207,6 +207,7 @@ abstract class Interpreter { public function getEntity() { return $this->channel; } public function getRowCount() { return $this->rowCount; } public function getTupleCount() { return $this->tupleCount; } + public function setTupleCount($count) { $this->tupleCount = $count; } public function getFrom() { return $this->from; } public function getTo() { return $this->to; } }