コード例 #1
0
ファイル: flash_chart.php プロジェクト: risnandar/testing
 /**
  * This is an alias to FlashChart::chart('pie') that is only used for the 
  * pie type.
  *
  * For options documentation; 
  * http://teethgrinder.co.uk/open-flash-chart-2/pie-chart.php
  * 
  * @example echo $flashChart->renderPie();
  * @example echo $flashChart->renderPie(array('animate'=>false);
  * @param array $options
  * 		Valid options : values, animate, start_angle, tooltip
  * @param string $datasetName The name to be used to associate charts with data
  * @param string $chartId Name of chart. Use for seperate charts.
  * @return string
  */
 public function pie($options = array(), $datasetName = 'default', $chartId = 'default')
 {
     if (empty($this->data[$datasetName])) {
         return false;
     }
     $this->Chart->set_bg_colour($this->bg_colour);
     $pie = new Pie();
     foreach ($options as $key => $setting) {
         $set_method = 'set_' . $key;
         $pie->{$set_method}($setting);
     }
     if (!empty($this->tooltip)) {
         $pie->set_tooltip($this->tooltip);
     }
     $pies = array();
     $labels = Set::extract($this->data, $this->labelsPath);
     $numbers = $this->getNumbers($datasetName);
     foreach ($numbers as $key => $value) {
         if (isset($labels[$key]) && is_string($labels[$key])) {
             $pies[] = new pie_value($value, $labels[$key]);
         } else {
             $pies[] = $value;
         }
     }
     $pie->set_values($pies);
     $this->Chart->add_element($pie);
     return $this->renderData($chartId);
 }