. */ require_once('HistogramTransform.php'); class MinField extends HistogramTransform { /** * @var string field holding the value */ var $valueField; /** * @var string field to group by */ var $groupByField; function __construct($valueField, $groupByField = null) { $this->valueField = $valueField; $this->groupByField = $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 if ($value < $this->values[$groupByName]) { $this->values[$groupByName] = $value; } } } } }