/** * Checks that the data are valid */ protected function CheckValues() { parent::CheckValues(); if ($this->GetMinValue() < 0) { throw new Exception('Negative value for pie chart'); } $sum = 0; foreach ($this->values[0] as $item) { $sum += $item->value; } if ($sum <= 0) { throw new Exception('Empty pie chart'); } $this->total = $sum; }
/** * Checks that the data are valid */ protected function CheckValues(&$values) { parent::CheckValues($values); if ($this->GetMinValue() < 0) { throw new Exception('Negative value for pie chart'); } if (array_sum($values[0]) <= 0) { throw new Exception('Empty pie chart'); } }