Example #1
0
 /**
  * Sets the graph values
  */
 public function Values($values)
 {
     $new_values = array();
     $v = func_get_args();
     if (count($v) == 1) {
         $v = array_shift($v);
     }
     $set_values = true;
     if (is_array($v)) {
         reset($v);
         $first_key = key($v);
         if (!is_null($first_key) && is_array($v[$first_key])) {
             foreach ($v as $data_set) {
                 $new_values[] = $data_set;
             }
             $set_values = false;
         }
     }
     if ($set_values) {
         $new_values[] = $v;
     }
     if ($this->scatter_2d) {
         $this->scatter_2d = false;
         if (empty($this->structure)) {
             $this->structure = array('key' => 0, 'value' => 1, 'datasets' => true);
         }
     }
     if ($this->datetime_keys && $this->datetime_key_format) {
         Graph::$key_format = $this->datetime_key_format;
     }
     if ($this->structured_data || is_array($this->structure)) {
         $this->structured_data = true;
         require_once 'SVGGraphStructuredData.php';
         $this->values = new SVGGraphStructuredData($new_values, $this->force_assoc, $this->datetime_keys, $this->structure, $this->repeated_keys, $this->require_integer_keys, $this->require_structured);
     } else {
         require_once 'SVGGraphData.php';
         $this->values = new SVGGraphData($new_values, $this->force_assoc, $this->datetime_keys);
         if (!$this->values->error && !empty($this->require_structured)) {
             $this->values->error = get_class($this) . ' requires structured data';
         }
     }
 }