_sid; $this->_sid = array_shift($args); break; case 'data': $args = array_shift($args); if ($this->_required_axis AND array_diff(array_keys($args),$this->_required_axis)) throw new Kohana_Exception('Invalid data arguments for chart, expecting [:args]',array(':args'=>implode('|',$this->_required_axis))); if (! $args) return $this->_sdata; $this->_sdata = $args; break; case 'index': if (! $args) return $this->_sindex; $this->_sindex = array_shift($args); break; case 'name': if (! $args) return $this->_stitle; $this->_stitle = array_shift($args); break; case 'order': if (! $args) return $this->_sorder; $this->_sorder = array_shift($args); break; default: throw new Kohana_Exception('Unknown method :name',array(':name'=>$name)); } return $this; } /** * Incrementally add to a series */ public function series_add($name,$v,$options=array()) { if (! empty($this->_sdata[$name])) throw new Kohana_Exception('Column :column already has some data',array(':column'=>$name)); $this->_sdata[$name] = $v; foreach ($options as $k=>$v) $this->_soptions[$k][$name] = $v; return $this; } /** * Calculate the total of all data in the series */ public function total() { return array_sum($this->_sdata); } }