Blame view

site/graphe.php 1.63 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);
39579493   root   MAJ Site
22
  $graph->title->Set('Capteur '.$_REQUEST['nom'].' : '.$legend['type'].' ('.$legend['unite'].')');
a4e386fb   root   Ajout graphe V1
23
24
  $graph->SetBox(false);
  
39579493   root   MAJ Site
25
  $graph->SetMargin(40,30,15,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);
39579493   root   MAJ Site
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);
39579493   root   MAJ Site
37
  $graph->xaxis->SetLabelAngle(90);
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);
39579493   root   MAJ Site
43
  $p->SetColor('#eb3d34');//('#5c0f10');
a4e386fb   root   Ajout graphe V1
44
  
39579493   root   MAJ Site
45
46
47
48
  if($_REQUEST['nombre'] <= 40)
  {
  	// Afficher les valeurs pour chaque point
  	$p->value->Show();
407dc302   root   Graphes ok
49
  
39579493   root   MAJ Site
50
51
52
53
  	// Valeurs: Apparence de la police
  	$p->value->SetFormat('%.1f');
  	$p->value->SetColor('#0c0f52');
  }
407dc302   root   Graphes ok
54
  
39579493   root   MAJ Site
55
  // Chaque point de la courbe 
407dc302   root   Graphes ok
56
57
58
  // Type de point
  $p->mark->SetType(MARK_FILLEDCIRCLE);
  // Couleur de remplissage
0071f5d7   root   MAJ
59
  $p->mark->SetFillColor('#0D0D0D');
407dc302   root   Graphes ok
60
  // Taille
39579493   root   MAJ Site
61
  $p->mark->SetWidth(2);
407dc302   root   Graphes ok
62
  
a4e386fb   root   Ajout graphe V1
63
64
65
66
67
  
  // Output line
  $graph->Stroke();
  
  ?>