Improvements to SSL classes
This commit is contained in:
@@ -18,8 +18,11 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
protected $_max = array();
|
||||
// Chart title
|
||||
protected $_title = '';
|
||||
protected $_dataurl = '';
|
||||
protected $_divname = '';
|
||||
// Default chart size.
|
||||
protected $_size = '700x200';
|
||||
protected $_height = '200';
|
||||
protected $_width = '700';
|
||||
|
||||
// Colors to use for series
|
||||
private $series_colors = array('AAACCC','E0E0E0','CCC888','EEEBBB','666CCC','888888');
|
||||
@@ -46,8 +49,16 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
|
||||
public function __call($name,$args) {
|
||||
switch ($name) {
|
||||
case 'dataurl': $this->_dataurl = array_shift($args);
|
||||
break;
|
||||
case 'div': $this->_divname = array_shift($args);
|
||||
break;
|
||||
case 'height': $this->_height = array_shift($args);
|
||||
break;
|
||||
case 'title': $this->_title = array_shift($args);
|
||||
break;
|
||||
case 'width': $this->_width = array_shift($args);
|
||||
break;
|
||||
default:
|
||||
throw new Kohana_Exception('Unknown method :name',array(':name'=>$name));
|
||||
}
|
||||
@@ -79,6 +90,9 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
return new $c();
|
||||
}
|
||||
|
||||
// Render the chart data in a json format
|
||||
abstract public function json();
|
||||
|
||||
// Our child class should define how to render as a string
|
||||
abstract public function render();
|
||||
|
||||
@@ -90,7 +104,7 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
* Example:
|
||||
* $this->data('yl'=>'Base Down Peak',array('11-12'=>1,'11-11'=>2));
|
||||
*/
|
||||
public function data(array $axis,array $data) {
|
||||
public function sdata(array $axis,array $data) {
|
||||
// Some sanity checking
|
||||
if (count($axis) != 1)
|
||||
throw new Kohana_Exception('We can only take 1 series at time.');
|
||||
@@ -115,6 +129,34 @@ abstract class GoogleChart implements Iterator,Countable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record on plot event
|
||||
* @param $data Should contain an "X" with a "YL" and/or "YR"
|
||||
*/
|
||||
public function pdata($x,array $data) {
|
||||
if (! is_string($x))
|
||||
throw new Kohana_Exception('X should be a string');
|
||||
|
||||
foreach ($data as $key => $values) {
|
||||
switch ($key) {
|
||||
case 'yr':
|
||||
case 'yl':
|
||||
foreach ($values as $k=>$v) {
|
||||
if (! in_array($k,$this->_axis))
|
||||
$this->_axis[$k] = $key;
|
||||
|
||||
$this->_data[$k][$x] = $v;
|
||||
$this->_plotdata[$x][$k] = $v;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Kohana_Exception('Unknown key :key',array(':key'=>$key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the colors that will be used for this series
|
||||
*/
|
||||
|
Reference in New Issue
Block a user