1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_line.php'); |
---|
4 | require_once ('jpgraph/jpgraph_date.php'); |
---|
5 | require_once ('jpgraph/jpgraph_mgraph.php'); |
---|
6 | |
---|
7 | // Setup some fake data to simulate some wind speed and direction |
---|
8 | |
---|
9 | DEFINE('NDATAPOINTS',280); |
---|
10 | DEFINE('SAMPLERATE',300); |
---|
11 | |
---|
12 | $start = time(); |
---|
13 | $end = $start+NDATAPOINTS*SAMPLERATE; |
---|
14 | $xdata = array(); |
---|
15 | |
---|
16 | $data_winddirection[0] = rand(20,30); |
---|
17 | $data_windspeed[0] = rand(100,200); |
---|
18 | $data_windtemp[0] = rand(10,30); |
---|
19 | |
---|
20 | for( $i=0; $i < NDATAPOINTS-1; ++$i ) { |
---|
21 | $data_winddirection[$i+1] = $data_winddirection[$i] + rand(-4,4); |
---|
22 | if($data_winddirection[$i+1] < 10 || $data_winddirection[$i+1] > 59) |
---|
23 | $data_winddirection[$i+1] = 47; |
---|
24 | |
---|
25 | $data_windspeed[$i+1] = $data_windspeed[$i] + rand(-2,2); |
---|
26 | if($data_windspeed[$i+1] < 0 ) |
---|
27 | $data_windspeed[$i+1] = 0; |
---|
28 | |
---|
29 | $data_windtemp[$i+1] = $data_windtemp[$i] + rand(-1.5,1.5); |
---|
30 | |
---|
31 | $xdata[$i] = $start + $i * SAMPLERATE; |
---|
32 | } |
---|
33 | $xdata[$i] = $start + $i * SAMPLERATE; |
---|
34 | |
---|
35 | |
---|
36 | //DEFINE('BKG_COLOR','lightgray:1.7'); |
---|
37 | DEFINE('BKG_COLOR','green:1.98'); |
---|
38 | DEFINE('WIND_HEIGHT',800); |
---|
39 | DEFINE('WIND_WIDTH',250); |
---|
40 | |
---|
41 | //------------------------------------------------------------------ |
---|
42 | // Setup the Temperature graph |
---|
43 | //------------------------------------------------------------------ |
---|
44 | $graph = new Graph(WIND_WIDTH,WIND_HEIGHT); |
---|
45 | $graph->SetMarginColor(BKG_COLOR); |
---|
46 | $graph->SetScale('datlin',0,60); |
---|
47 | $graph->Set90AndMargin(50,10,70,30); |
---|
48 | $graph->SetFrame(true,'white',0); |
---|
49 | $graph->SetBox(); |
---|
50 | |
---|
51 | $graph->title->Set('Temperature'); |
---|
52 | $graph->title->SetColor('red'); |
---|
53 | $graph->title->SetFont(FF_FONT1,FS_BOLD,48); |
---|
54 | $graph->title->SetMargin(5); |
---|
55 | |
---|
56 | $graph->xaxis->SetFont(FF_FONT0,FS_NORMAL,9); |
---|
57 | $graph->xaxis->scale->SetDateFormat('H:i'); |
---|
58 | $graph->xgrid->Show(); |
---|
59 | |
---|
60 | $graph->yaxis->SetLabelAngle(90); |
---|
61 | $graph->yaxis->SetColor('red'); |
---|
62 | $graph->yaxis->SetFont(FF_FONT0,FS_NORMAL,9); |
---|
63 | $graph->yaxis->SetLabelMargin(0); |
---|
64 | $graph->yaxis->scale->SetAutoMin(10); |
---|
65 | |
---|
66 | $line = new LinePlot($data_winddirection,$xdata); |
---|
67 | $line->SetStepStyle(); |
---|
68 | $line->SetColor('red'); |
---|
69 | |
---|
70 | $graph->AddLine($line); |
---|
71 | |
---|
72 | //$graph->Add($line); |
---|
73 | |
---|
74 | //------------------------------------------------------------------ |
---|
75 | // Setup the Vacuum graph |
---|
76 | //------------------------------------------------------------------ |
---|
77 | $graph2 = new Graph(WIND_WIDTH-30,WIND_HEIGHT); |
---|
78 | $graph2->SetScale('datlin'); |
---|
79 | $graph2->Set90AndMargin(5,20,70,30); |
---|
80 | $graph2->SetMarginColor(BKG_COLOR); |
---|
81 | $graph2->SetFrame(true,'white',0); |
---|
82 | $graph2->SetBox(); |
---|
83 | |
---|
84 | $graph2->title->Set('Vacuum'); |
---|
85 | $graph2->title->SetColor('blue'); |
---|
86 | $graph2->title->SetFont(FF_FONT1,FS_BOLD,48); |
---|
87 | $graph2->title->SetMargin(5); |
---|
88 | |
---|
89 | $graph2->xaxis->HideLabels(); |
---|
90 | $graph2->xgrid->Show(); |
---|
91 | |
---|
92 | $graph2->yaxis->SetLabelAngle(90); |
---|
93 | $graph2->yaxis->SetColor('blue'); |
---|
94 | $graph2->yaxis->SetFont(FF_FONT0,FS_NORMAL,9); |
---|
95 | $graph2->yaxis->SetLabelMargin(0); |
---|
96 | $graph2->yaxis->scale->SetAutoMin(50); |
---|
97 | |
---|
98 | $line2 = new LinePlot($data_windspeed,$xdata); |
---|
99 | $line2->SetStepStyle(); |
---|
100 | $line2->SetColor('blue'); |
---|
101 | |
---|
102 | $graph2->AddLine($line2); |
---|
103 | |
---|
104 | //$graph2->Add($line2); |
---|
105 | |
---|
106 | //------------------------------------------------------------------ |
---|
107 | // Setup the power graph |
---|
108 | //------------------------------------------------------------------ |
---|
109 | $graph3 = new Graph(WIND_WIDTH-30,WIND_HEIGHT); |
---|
110 | $graph3->SetScale('datlin'); |
---|
111 | $graph3->Set90AndMargin(5,20,70,30); |
---|
112 | $graph3->SetMarginColor(BKG_COLOR); |
---|
113 | $graph3->SetFrame(true,'white',0); |
---|
114 | $graph3->SetBox(); |
---|
115 | |
---|
116 | $graph3->title->Set('RF Power'); |
---|
117 | $graph3->title->SetColor('black'); |
---|
118 | $graph3->title->SetFont(FF_FONT1,FS_BOLD,48); |
---|
119 | $graph3->title->SetMargin(5); |
---|
120 | |
---|
121 | $graph3->xaxis->HideLabels(); |
---|
122 | $graph3->xgrid->Show(); |
---|
123 | |
---|
124 | $graph3->yaxis->SetLabelAngle(90); |
---|
125 | $graph3->yaxis->SetColor('black'); |
---|
126 | $graph3->yaxis->SetFont(FF_FONT0,FS_NORMAL,9); |
---|
127 | $graph3->yaxis->SetLabelMargin(0); |
---|
128 | $graph3->yaxis->scale->SetAutoMin(-10); |
---|
129 | |
---|
130 | $line3 = new LinePlot($data_windtemp,$xdata); |
---|
131 | $line3->SetStepStyle(); |
---|
132 | $line3->SetColor('black'); |
---|
133 | |
---|
134 | $graph3->AddLine($line3); |
---|
135 | |
---|
136 | //$graph3->Add($line3); |
---|
137 | |
---|
138 | //----------------------- |
---|
139 | // Create a multigraph |
---|
140 | //---------------------- |
---|
141 | $mgraph = new MGraph(); |
---|
142 | $mgraph->SetMargin(2,2,2,2); |
---|
143 | $mgraph->SetFrame(true,'darkgray',2); |
---|
144 | $mgraph->SetFillColor(BKG_COLOR); |
---|
145 | $mgraph->Add($graph,0,50); |
---|
146 | $mgraph->Add($graph2,250,50); |
---|
147 | $mgraph->Add($graph3,460,50); |
---|
148 | $mgraph->title->Set('XFEL Stand A August 2013'); |
---|
149 | $mgraph->title->SetFont(FF_FONT2,FS_BOLD,80); |
---|
150 | $mgraph->title->SetMargin(8); |
---|
151 | $mgraph->Stroke(); |
---|
152 | |
---|
153 | ?> |
---|