graphe.php
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?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");
$datay = array_reverse($y);
$datax = array_reverse($x);
// 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('Capteur '.$_REQUEST['nom']);
$graph->SetBox(false);
$graph->SetMargin(40,30,40,50);
$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 line
$p = new LinePlot($datay);
$graph->Add($p);
$p->SetColor("#6495ED");
// Afficher les valeurs pour chaque point
$p->value->Show();
// Valeurs: Apparence de la police
$p->value->SetFormat('%.1f');
$p->value->SetColor("red");
// Chaque point de la courbe ****
// Type de point
$p->mark->SetType(MARK_FILLEDCIRCLE);
// Couleur de remplissage
$p->mark->SetFillColor("green");
// Taille
$p->mark->SetWidth(5);
// Output line
$graph->Stroke();
?>