live = (boolean) $live;
$this->live_delay = (int) $live_delay;
$this->live_url = trim($url);
}
function addDataSet($data, $title, $color) {
$this->data[] = new CHART_DATA($data, $title, $color);
}
function render() {
return $this->render_header() . $this->render_data() . $this->render_footer();
}
private function render_data() {
$buf = "";
$buf .= "";
$buf .="\n\n";
if(isset($this->data[0])) {
for($c = count($this->data[0]->data), $i=1; $i <= $c; $i++) {
$buf .= "{$i}\n";
}
}
$buf .="
";
foreach($this->data as $chart_data) {
$buf .= "\n{$chart_data->title}\n";
foreach($chart_data->data as $value) {
$buf .= "{$value}\n";
}
$buf .= "
";
}
$buf .="";
return $buf;
}
private function render_header() {
$buf = "
\n";
$buf .= "\n";
foreach($this->data as $set) {
$buf .= "{$set->color}\n";
}
$buf .= "\n";
return $buf;
}
private function render_footer() {
$buf = "
Line
{$this->yaxis_label}
";
if($this->live) {
$buf .= "\n";
}
$buf .= "";
return $buf;
}
}
class CHART_DATA {
var $data = array();
//options
var $title = NULL;
var $color = NULL;
function CHART_DATA(&$data, $title, $color) {
$this->data = &$data;
$this->title = &$title;
$this->color = &$color;
}
}