Blame view

site/graphe.php 1.53 KB
a4e386fb   root   Ajout graphe V1
1
  <?php // content="text/plain; charset=utf-8"
e65076e1   root   MAJ
2
3
  require_once ('jpgraph/jpgraph.php');
  require_once ('jpgraph/jpgraph_line.php');
ab15bd74   Guillaume   Test Graphe
4
  require_once('accesBase.php');
a4e386fb   root   Ajout graphe V1
5
  
0071f5d7   root   MAJ
6
  $legend = getLegend($_REQUEST['nom']);
e7a12237   Guillaume   Test Graphe
7
  $history = getHistory($_REQUEST['nom'], '', '', $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['nombre']);
44a425e3   Guillaume   Test Graphe
8
9
  $y = makeArray($history, "value");
  $x = makeArray($history, "date");
44a425e3   Guillaume   Test Graphe
10
  
44eb6b3e   Guillaume   Test Graphe
11
12
  $datay = array_reverse($y);
  $datax = array_reverse($x);
a4e386fb   root   Ajout graphe V1
13
14
  
  // Setup the graph
0071f5d7   root   MAJ
15
  $graph = new Graph(1100,400);
a4e386fb   root   Ajout graphe V1
16
17
18
19
20
21
  $graph->SetScale("textlin");
  
  $theme_class=new UniversalTheme;
  
  $graph->SetTheme($theme_class);
  $graph->img->SetAntiAliasing(false);
407dc302   root   Graphes ok
22
  $graph->title->Set('Capteur '.$_REQUEST['nom']);
a4e386fb   root   Ajout graphe V1
23
24
  $graph->SetBox(false);
  
0071f5d7   root   MAJ
25
  $graph->SetMargin(40,30,40,150);
a4e386fb   root   Ajout graphe V1
26
27
28
29
30
31
  
  $graph->img->SetAntiAliasing();
  
  $graph->yaxis->HideZeroLabel();
  $graph->yaxis->HideLine(false);
  $graph->yaxis->HideTicks(false,false);
0071f5d7   root   MAJ
32
  $graph->yaxis->title->Set($legend['type']."(".$legend['unite'].")");
a4e386fb   root   Ajout graphe V1
33
34
35
  
  $graph->xgrid->Show();
  $graph->xgrid->SetLineStyle("solid");
44a425e3   Guillaume   Test Graphe
36
  $graph->xaxis->SetTickLabels($datax);
0071f5d7   root   MAJ
37
  $graph->xaxis->SetLabelAngle(80);
a4e386fb   root   Ajout graphe V1
38
39
  $graph->xgrid->SetColor('#E3E3E3');
  
407dc302   root   Graphes ok
40
  // Create the line
e7a12237   Guillaume   Test Graphe
41
42
  $p = new LinePlot($datay);
  $graph->Add($p);
0071f5d7   root   MAJ
43
  $p->SetColor('#5c0f10');
a4e386fb   root   Ajout graphe V1
44
  
407dc302   root   Graphes ok
45
46
47
48
49
  // Afficher les valeurs pour chaque point
  $p->value->Show();
  
  // Valeurs: Apparence de la police
  $p->value->SetFormat('%.1f');
0071f5d7   root   MAJ
50
  $p->value->SetColor('#0c0f52');
407dc302   root   Graphes ok
51
52
53
54
55
  
  // Chaque point de la courbe ****
  // Type de point
  $p->mark->SetType(MARK_FILLEDCIRCLE);
  // Couleur de remplissage
0071f5d7   root   MAJ
56
  $p->mark->SetFillColor('#0D0D0D');
407dc302   root   Graphes ok
57
58
59
  // Taille
  $p->mark->SetWidth(5);
  
a4e386fb   root   Ajout graphe V1
60
61
62
63
64
  
  // Output line
  $graph->Stroke();
  
  ?>