}
+$supported = imagetypes();
+if( $supported & IMG_PNG ) $img_format="png";
+elseif( $supported & IMG_GIF ) $img_format="gif";
+elseif( $supported & IMG_JPG ) $img_format="jpeg";
+elseif( $supported & IMG_WBMP ) $img_format="wbmp";
+elseif( $supported & IMG_XPM ) $img_format="xpm";
+
+$cachefilename = NULL;
+
$db -> exec('SET CHARACTER SET utf8');
$type = $_REQUEST['type'];
} elseif ($type == 'range') {
+ $curr = intval(date('YmdHis'));
+
$from = intval($_REQUEST['fromdate']);
$to = intval($_REQUEST['todate']);
+ if ($curr>$to) {
+
+ $cachefilename='meteo.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$from.'-'.$to.'.'.$img_format;
+
+ }
+
$q = $db -> prepare(
'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>=str_to_date("'.$from.'","%Y%m%d%H%i%s") and timestamp<=str_to_date("'.$to.'","%Y%m%d%H%i%s") and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp'
);
}
+ $g = new Graph(640,480);
+
+ if ($cachefilename) {
+ if ($g->cache->IsValid($cachefilename)) {
+
+ $g->cache->StreamImgFile($g->img,$cachefilename);
+ return;
+
+ } else {
+
+ $timeout = 8640000;
+ $g->SetupCache($cachefilename,$timeout);
+
+ }
+ }
+
$q -> execute();
while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
$total_weight=0;
$sum=0;
- $maxdelta = 900;
+ $maxdelta = 1800;
for ($j = $i; $j < count($xdata); ++$j) {
}
// Create the graph
- $g = new Graph(640,480);
$g->graph_theme = null;
- //$g->img->SetAntiAliasing();
+ $g->img->SetAntiAliasing();
- // We need a linlin scale since we provide both
- // x and y coordinates for the data points.
+ // We need a datlin scale since we provide both
+ // x and y coordinates for the data points, but x is unix timestamp.
$g->SetScale('datlin');
$g->xaxis->SetLabelAngle(90);
$g->xaxis->SetPos("min");
+ $g->xaxis->scale->SetTimeAlign( HOURADJ_1 );
// We use a scatterplot to illustrate the original
// contro points.
$g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12);
$g->SetMarginColor('silver');
+ $g->xgrid->Show();
+ $g->xgrid->SetLineStyle('dotted');
+ $g->ygrid->Show();
+ $g->ygrid->SetLineStyle('dotted');
+
// Add the plots to the graph and stroke
$g->Stroke();