Esempio n. 1
0
 /**
  * Alias for FlashChart::chart('scatter'), this method renders only
  * the scatter chart type
  *
  * Online documentation :
  * http://teethgrinder.co.uk/open-flash-chart-2/scatter-chart.php
  * 
  * @param array $options
  * 		valid option keys : colour, size, x_key, y_key
  * @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 scatter($options = array(), $datasetName = 'default', $chartId = 'default')
 {
     if (empty($this->data[$datasetName])) {
         return false;
     }
     $options = am($this->scatter_options, $options);
     if (isset($options['type']) && $options['type'] == 'scatter_line') {
         $scatter = new scatter_line($options['colour'], $options['size']);
     } else {
         $scatter = new scatter($options['colour'], $options['size']);
     }
     $values = array();
     foreach ($this->data[$datasetName] as $row) {
         $values[] = new scatter_value($row[$options['x_key']], $row[$options['y_key']]);
     }
     if (!empty($this->tooltip)) {
         $element->set_tooltip($this->tooltip);
     }
     $scatter->set_values($values);
     $this->Chart->add_element($scatter);
     $this->Chart->set_bg_colour($this->bg_colour);
     return $this->renderData($chartId);
 }
Esempio n. 2
0
 /**
  * Alias for FlashChart::chart('scatter'), this method renders only
  * the scatter chart type
  *
  * Online documentation :
  * http://teethgrinder.co.uk/open-flash-chart-2/scatter-chart.php
  * 
  * @param array $options
  * 		valid option keys : colour, size, x_key, y_key
  * @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 scatter($options = array(), $datasetName = 'default', $chartId = 'default')
 {
     if (empty($this->data[$datasetName])) {
         return false;
     }
     $options = am($this->scatter_options, $options);
     if (isset($options['type']) && $options['type'] == 'scatter_line') {
         $scatter = new scatter_line($options['colour'], $options['size']);
     } else {
         $scatter = new scatter($options['colour'], $options['size']);
     }
     $return = array();
     $values = Set::combine($this->data[$datasetName], '/Update/value', '/Update/id');
     $keys = array_keys($values);
     foreach ($keys as $x) {
         $return[] = new scatter_value($values[$x], $x);
     }
     $values = $return;
     if (!empty($this->tooltip)) {
         $element->set_tooltip($this->tooltip);
     }
     $scatter->set_values($values);
     $this->Chart->add_element($scatter);
     $this->Chart->set_bg_colour($this->bg_colour);
     return $this->renderData($chartId);
 }