<?php
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_log.php");
include ("jpgraph/src/jpgraph_line.php");
class LinePlotter{
private $graph;
private $gambar;
private $redvalue;
private $data;
private $legend;
private $interval;
public function __construct($data){
$this->data = $data;
}
public function setRedLine($red){
$this->redvalue = $red;
}
public function setLegend($legend){
$this->legend = $legend;
}
public function stroke($file){
$posttime = array();
$datay = array();
$redline = array();
foreach($this->data as $key=>$value){
$posttime[] = $key;
$datay[] = $value;
if(isset($this->redvalue)){
$redline[] = $this->redvalue;
}
}
// Setup the graph
$this->graph = new Graph(510,300);
$this->graph->SetScale("textlin");
$this->graph->SetMarginColor('white');
$this->graph->SetFrame(false);
$this->graph->SetMargin(30,50,30,30);
// Create the first line
$p1 = new LinePlot($datay);
$p1->SetColor("navy");
$p1->SetLegend($this->legend);
$this->graph->Add($p1);
if(isset($this->redvalue)){
// Create red line
$p3 = new LinePlot($redline);
$p3->SetColor("red");
$p3->SetStyle("dashed");
$this->graph->Add($p3);
}
$this->graph->Stroke('/www/htdocs/ajaxmonyet/tmp/'.$file);
}
public function strokeMe(){
$this->graph->Stroke();
}
}
$driver = new LinePlotter(array('2'=>'3','12'=>'13'));
$driver->stroke('test.jpg');
?>