| 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->Add($line); | 
|---|
| 71 |  | 
|---|
| 72 | //------------------------------------------------------------------ | 
|---|
| 73 | // Setup the Vacuum graph | 
|---|
| 74 | //------------------------------------------------------------------ | 
|---|
| 75 | $graph2 = new Graph(WIND_WIDTH-30,WIND_HEIGHT); | 
|---|
| 76 | $graph2->SetScale('datlin'); | 
|---|
| 77 | $graph2->Set90AndMargin(5,20,70,30); | 
|---|
| 78 | $graph2->SetMarginColor(BKG_COLOR); | 
|---|
| 79 | $graph2->SetFrame(true,'white',0); | 
|---|
| 80 | $graph2->SetBox(); | 
|---|
| 81 |  | 
|---|
| 82 | $graph2->title->Set('Vacuum'); | 
|---|
| 83 | $graph2->title->SetColor('blue'); | 
|---|
| 84 | $graph2->title->SetFont(FF_FONT1,FS_BOLD,48); | 
|---|
| 85 | $graph2->title->SetMargin(5); | 
|---|
| 86 |  | 
|---|
| 87 | $graph2->xaxis->HideLabels(); | 
|---|
| 88 | $graph2->xgrid->Show(); | 
|---|
| 89 |  | 
|---|
| 90 | $graph2->yaxis->SetLabelAngle(90); | 
|---|
| 91 | $graph2->yaxis->SetColor('blue'); | 
|---|
| 92 | $graph2->yaxis->SetFont(FF_FONT0,FS_NORMAL,9); | 
|---|
| 93 | $graph2->yaxis->SetLabelMargin(0); | 
|---|
| 94 | $graph2->yaxis->scale->SetAutoMin(50); | 
|---|
| 95 |  | 
|---|
| 96 | $line2 = new LinePlot($data_windspeed,$xdata); | 
|---|
| 97 | $line2->SetStepStyle(); | 
|---|
| 98 | $line2->SetColor('blue'); | 
|---|
| 99 |  | 
|---|
| 100 | $graph2->Add($line2); | 
|---|
| 101 |  | 
|---|
| 102 | //------------------------------------------------------------------ | 
|---|
| 103 | // Setup the power graph | 
|---|
| 104 | //------------------------------------------------------------------ | 
|---|
| 105 | $graph3 = new Graph(WIND_WIDTH-30,WIND_HEIGHT); | 
|---|
| 106 | $graph3->SetScale('datlin'); | 
|---|
| 107 | $graph3->Set90AndMargin(5,20,70,30); | 
|---|
| 108 | $graph3->SetMarginColor(BKG_COLOR); | 
|---|
| 109 | $graph3->SetFrame(true,'white',0); | 
|---|
| 110 | $graph3->SetBox(); | 
|---|
| 111 |  | 
|---|
| 112 | $graph3->title->Set('RF Power'); | 
|---|
| 113 | $graph3->title->SetColor('black'); | 
|---|
| 114 | $graph3->title->SetFont(FF_FONT1,FS_BOLD,48); | 
|---|
| 115 | $graph3->title->SetMargin(5); | 
|---|
| 116 |  | 
|---|
| 117 | $graph3->xaxis->HideLabels(); | 
|---|
| 118 | $graph3->xgrid->Show(); | 
|---|
| 119 |  | 
|---|
| 120 | $graph3->yaxis->SetLabelAngle(90); | 
|---|
| 121 | $graph3->yaxis->SetColor('black'); | 
|---|
| 122 | $graph3->yaxis->SetFont(FF_FONT0,FS_NORMAL,9); | 
|---|
| 123 | $graph3->yaxis->SetLabelMargin(0); | 
|---|
| 124 | $graph3->yaxis->scale->SetAutoMin(-10); | 
|---|
| 125 |  | 
|---|
| 126 | $line3 = new LinePlot($data_windtemp,$xdata); | 
|---|
| 127 | $line3->SetStepStyle(); | 
|---|
| 128 | $line3->SetColor('black'); | 
|---|
| 129 |  | 
|---|
| 130 | $graph3->Add($line3); | 
|---|
| 131 |  | 
|---|
| 132 | //----------------------- | 
|---|
| 133 | // Create a multigraph | 
|---|
| 134 | //---------------------- | 
|---|
| 135 | $mgraph = new MGraph(); | 
|---|
| 136 | $mgraph->SetMargin(2,2,2,2); | 
|---|
| 137 | $mgraph->SetFrame(true,'darkgray',2); | 
|---|
| 138 | $mgraph->SetFillColor(BKG_COLOR); | 
|---|
| 139 | $mgraph->Add($graph,0,50); | 
|---|
| 140 | $mgraph->Add($graph2,250,50); | 
|---|
| 141 | $mgraph->Add($graph3,460,50); | 
|---|
| 142 | $mgraph->title->Set('XFEL Stand A July 2013'); | 
|---|
| 143 | $mgraph->title->SetFont(FF_FONT2,FS_BOLD,80); | 
|---|
| 144 | $mgraph->title->SetMargin(8); | 
|---|
| 145 | $mgraph->Stroke(); | 
|---|
| 146 |  | 
|---|
| 147 | ?> | 
|---|