Files
2026-02-17 09:29:34 -06:00

91 lines
2.4 KiB
PHP

<?php
// content="text/plain; charset=utf-8"
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_line.php');
// FOR DB CONNECTION
$link = mysql_connect('controls2k8', 'corey', '41945549')
or die('Could not connect: ' . mysql_error());
mysql_select_db('controls') or die('Could not select database');
$dataArray=array();
//get data from database
$sql="SELECT timestamp, prevtons, lbsperhr FROM trending where trending.id mod 2880 = 0 GROUP BY timestamp DESC LIMIT 100";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$datay[] = $row["timestamp"];
$datax1[] = $row["prevtons"];
$datax2[] = $row["lbsperhr"];
}
}
$n = 5;
for($i=0; $i < $n; ++$i ) {
$targ1[$i] = "#$i";
$targ2[$i] = "#$i";
$targ3[$i] = "#$i";
$alts1[$i] = "Previous Day Ground=%d";
$alts2[$i] = "LBS Steam Per Hour=%d";
$alts3[$i] = "val=%d";
}
// Setup the graph
$graph = new Graph(1600,520);
$graph->SetScale('linlin',0,14000);
$graph->yaxis->scale->ticks->Set(5,10);
$graph->xaxis->scale->ticks->Set(5);
$theme_class=new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Graph');
$graph->img->SetMargin(70,15,30,125); // Sets the margin. L, R, T, B
$graph->title->Set('Previous Day Ground and LBS Steam Per Hour');
$graph->subtitle->Set('(Every 24 Hours)');
$graph->xaxis->title->Set();
$graph->yaxis->title->Set('%');
$graph->SetBox(false);
$graph->legend->SetPos($aX,$aY,$aHAlign='right',$aVAlign='top');
$graph->img->SetAntiAliasing();
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$graph->yaxis->title->Set('');
$graph->yaxis->SetTitleMargin(50);
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xaxis->SetTickLabels($datay);
$graph->xaxis->SetLabelAngle(65);
$graph->xgrid->SetColor('#E3E3E3');
// Create line 1
$p1=new LinePlot($datax1);
$p1->SetCSIMTargets($targ1,$alts1);
$graph->Add($p1);
$p1->SetColor("#B22222");
$p1->mark->SetType(MARK_CIRCLE);
$p1->SetLegend('Previous Day Ground');
// Create line 2
$p2=new LinePlot($datax2);
$p2->SetCSIMTargets($targ2,$alts2);
$graph->Add($p2);
$p2->SetColor("#6495ED");
$p2->mark->SetType(MARK_CIRCLE);
$p2->SetLegend('LBS Steam Per Hour');
$graph->legend->SetFrameWeight(1);
// Output line
$graph->StrokeCSIM('../trends/lbsperhr24.php');
?>