source: trunk/xgraph/xfelgraph-pic.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 2.7 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4require_once ('jpgraph/jpgraph_date.php');
5require_once ('jpgraph/jpgraph_mgraph.php');
6
7
8DEFINE('NDATAPOINTS',28000);
9DEFINE('SAMPLERATE',300);
10
11$start = time();
12$end = $start+NDATAPOINTS*SAMPLERATE;
13$xdata_pic = array();
14
15
16//lecture data base
17$db = mysql_connect('127.0.0.1', 'root', '');   // connexion
18mysql_select_db('xfel',$db);                // selection
19
20
21//$req_pic    = mysql_query("SELECT Pic FROM power WHERE id_stand='b'and id_conditioning=208");// requetes
22//$req_measure = mysql_query("SELECT hour FROM measure");
23$req_hour_pic = mysql_query("SELECT measure.hour AS 'Date', power.Pic AS 'Pic' FROM measure INNER JOIN power ON (measure.id_measure=power.id_measure AND measure.id_conditioning=power.id_conditioning) WHERE measure.id_conditioning = 208 AND power.id_stand = 'b'");
24
25// on fait une boucle qui va faire un tour pour chaque enregistrement
26$index=0; 
27while($data=mysql_fetch_assoc($req_hour_pic)) 
28    { 
29    $data_pic[$index] = $data['Pic'];
30    $data_measure[$index] = $data['Date'];
31    $index++;
32    }
33
34mysql_close($db);// fermeture connexion
35
36for( $i=0; $i < $index; ++$i ) {
37   $xdata[$i] = $data_measure[$i];
38}
39
40$xdata[$i] = $start + $i * SAMPLERATE;
41
42//DEFINE('BKG_COLOR','lightgray:1.7');
43DEFINE('BKG_COLOR','green:1.98');
44DEFINE('WIND_HEIGHT',800);
45DEFINE('WIND_WIDTH',250);
46
47
48//------------------------------------------------------------------
49// Setup the Pic graph
50//------------------------------------------------------------------
51$graph = new Graph(WIND_WIDTH,WIND_HEIGHT);
52$graph->SetMarginColor(BKG_COLOR);
53$graph->SetScale('datlin',0,1000);
54$graph->Set90AndMargin(50,10,70,30);
55$graph->SetFrame(true,'white',0);
56$graph->SetBox();
57
58$graph->title->Set('Pic');
59$graph->title->SetColor('red');
60$graph->title->SetFont(FF_FONT1,FS_BOLD,48);
61$graph->title->SetMargin(5);
62
63$graph->xaxis->SetFont(FF_FONT0,FS_NORMAL,9);
64
65$graph->xaxis->SetTickLabels($xdata);
66
67$graph->xgrid->Show();
68
69$graph->yaxis->SetLabelAngle(90);
70$graph->yaxis->SetColor('red');
71$graph->yaxis->SetFont(FF_FONT0,FS_NORMAL,9);
72$graph->yaxis->SetLabelMargin(0);
73$graph->yaxis->scale->SetAutoMin(10);
74
75$line = new LinePlot($data_pic);
76$line->SetStepStyle();
77$line->SetColor('red');
78
79$graph->AddLine($line);
80
81//-----------------------
82// Create a multigraph
83//----------------------
84$mgraph = new MGraph();
85$mgraph->SetMargin(2,2,2,2);
86$mgraph->SetFrame(true,'darkgray',2);
87$mgraph->SetFillColor(BKG_COLOR);
88$mgraph->Add($graph,460,50);
89$mgraph->title->Set('XFEL Banc B 20 Septembre 2013');
90$mgraph->title->SetFont(FF_FONT2,FS_BOLD,80);
91$mgraph->title->SetMargin(8);
92$mgraph->Stroke();
93
94?>
Note: See TracBrowser for help on using the repository browser.