示例#1
0
 /**
  * Reduce number of values in the plot
  *
  * @param int $number Reduce number of values to $number
  */
 public function reduce($number)
 {
     $count = count($this->datay);
     $ratio = ceil($count / $number);
     if ($ratio > 1) {
         $tmpy = $this->datay;
         $datay = array();
         $datax = array();
         $cbLabel = $this->xAxis->label->getCallbackFunction();
         for ($i = 0; $i < $count; $i += $ratio) {
             $slice = array_slice($tmpy, $i, $ratio);
             $datay[] = array_sum($slice) / count($slice);
             // Reduce data on X axis if needed
             if ($cbLabel !== NULL) {
                 $datax[] = $cbLabel($i + round($ratio / 2));
             }
         }
         $this->setValues($datay);
         if ($cbLabel !== NULL) {
             $this->xAxis->setLabelText($datax);
         }
     }
 }