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

$legend = getLegend($_REQUEST['nom']);
$history = getHistory($_REQUEST['nom'], '', '', $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['nombre']);
$y = makeArray($history, "value");
$x = makeArray($history, "date");

$datay = array_reverse($y);
$datax = array_reverse($x);

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

$theme_class=new UniversalTheme;

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Capteur '.$_REQUEST['nom'].' : '.$legend['type'].' ('.$legend['unite'].')');
$graph->SetBox(false);

$graph->SetMargin(40,30,15,150);

$graph->img->SetAntiAliasing();

$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
//$graph->yaxis->title->Set($legend['type']."(".$legend['unite'].")");

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

// Create the line
$p = new LinePlot($datay);
$graph->Add($p);
$p->SetColor('#eb3d34');//('#5c0f10');

if($_REQUEST['nombre'] <= 40)
{
	// Afficher les valeurs pour chaque point
	$p->value->Show();

	// Valeurs: Apparence de la police
	$p->value->SetFormat('%.1f');
	$p->value->SetColor('#0c0f52');
}

// Chaque point de la courbe 
// Type de point
$p->mark->SetType(MARK_FILLEDCIRCLE);
// Couleur de remplissage
$p->mark->SetFillColor('#0D0D0D');
// Taille
$p->mark->SetWidth(2);


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

?>