. */ require_once('HistogramTransform.php'); class SumField extends HistogramTransform { function __construct($valueField, $groupByField = null) { parent::__construct($valueField, $groupByField); } public function addEntry(&$entry) { if (array_key_exists($this->valueField, $entry) && is_numeric($entry[$this->valueField])) { $value = $entry[$this->valueField]; $groupByName = empty($this->groupByField) ? $this->valueField : $entry[$this->groupByField]; if ($value !== null && $value !== '') { if (!array_key_exists($groupByName, $this->values)) { $this->values[$groupByName] = $value; } else { $this->values[$groupByName] += $value; } } } } }