graphe.php 1.18 KB
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once('accesBase.php');

$history = getHistory($_REQUEST['nom'], '', '', $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['nombre']);
$y = makeArray($history, "value");
$x = makeArray($history, "date");
//str_replace(" ", "\n", $datax);

for(int i=0; i<count($y); i++)
{
	$datay[] = $y[count($y)-i-1];
	$datax[] = $x[count($y)-i-1];
}

// Setup the graph
$graph = new Graph(800,400);
$graph->SetScale("textlin");

$theme_class=new UniversalTheme;

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Filled Y-grid');
$graph->SetBox(false);

$graph->SetMargin(40,20,36,63);

$graph->img->SetAntiAliasing();

$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);

$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xaxis->SetTickLabels($datax);
$graph->xgrid->SetColor('#E3E3E3');

// Create the first line
$p = new LinePlot($datay);
$graph->Add($p);
$p->SetColor("#6495ED");
$p->SetLegend('Capteur');

$graph->legend->SetFrameWeight(1);

// Output line
$graph->Stroke();

?>