示例#1
0
 protected function compute(array &$q)
 {
     if ($this->rotation) {
         $q['chp'] = $this->rotation;
     }
     parent::compute($q);
     // pie chart doesn't support data scaling.
     // however, i still want to compute a scale for encoding format
     unset($q['chds']);
 }
 /**
  * This function needs to do some funky stuffs with the data series, because
  * the chd parameter of scatter charts work quite differently.
  * chd=<x_values>|<y_values>[|<optional_point_sizes>]
  *
  * So basically each point must be split into 3 values, placed on 3 GoogleChartData objects.
  */
 protected function compute(array &$q)
 {
     $old_data = $this->data;
     $colors = array();
     // rebuild a set of 3 GoogleChartData
     $series_x = array();
     $series_y = array();
     $series_size = array();
     $legends = array();
     foreach ($this->data as $i => $data) {
         $colors[] = $data->computeChco();
         $legends[] = $data->getLegend();
         $data_x = array();
         $data_y = array();
         $data_size = array();
         foreach ($data->getValues() as $d) {
             $data_x[] = $d[0];
             $data_y[] = $d[1];
             $data_size[] = isset($d[2]) ? $d[2] : 10;
         }
         $series_x[] = $data_x;
         $series_y[] = $data_y;
         $series_size[] = $data_size;
     }
     $series_x = self::interlace($series_x);
     $series_y = self::interlace($series_y);
     $series_size = self::interlace($series_size);
     $series_x = new GoogleChartData($series_x);
     $series_y = new GoogleChartData($series_y);
     $series_size = new GoogleChartData($series_size);
     $this->data = array($series_x, $series_y, $series_size);
     $this->setAutoScale(false);
     // rebuild the legends
     $series_x->setLegends($legends);
     // compute
     parent::compute($q);
     unset($q['chds']);
     // DEBUG
     $this->chco = implode('|', $colors);
     $this->data = $old_data;
 }
 protected function compute(array &$q)
 {
     if (!$this->data[0]) {
         throw new Exception('Venn diagram needs one data series with 2 or 3 circles');
     }
     $values = $this->data[0]->getValues();
     if (!isset($values[2])) {
         // only 2 circles
         $values[2] = 0;
     }
     $values[] = $this->intersect_ab;
     if ($values[2] != 0) {
         $values[] = $this->intersect_ac;
         $values[] = $this->intersect_bc;
         $values[] = $this->intersect_abc;
     }
     $this->data[0]->setValues($values);
     parent::compute($q);
     if (isset($q['chco'])) {
         $q['chco'] = str_replace('|', ',', $q['chco']);
     }
 }
 protected function compute(array &$q)
 {
     $q['chbh'] = $this->computeChbh();
     parent::compute($q);
 }