X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/e4e1557426f8e5ca10ca616140528939d86426cd..3fd934fc66956e08777aaa10bd2ee27c1bc62758:/web/image.php?ds=sidebyside diff --git a/web/image.php b/web/image.php index eaa6fda..bf511f2 100644 --- a/web/image.php +++ b/web/image.php @@ -82,7 +82,23 @@ if ($type and $param) { 'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>adddate(now(), -1) and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp' ); - $height = 130; + $bottomheight = 130; + $topheight = 40; + $sizex = 1000; + $sizey = 800; + $scale = True; + + } elseif ($type == 'last24small') { + + $q = $db -> prepare( + 'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>adddate(now(), -1) and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp' + ); + + $bottomheight = 20; + $topheight = 20; + $sizex = 400; + $sizey = 300; + $scale = False; } elseif ($type == 'range') { @@ -93,7 +109,7 @@ if ($type and $param) { if ($curr>$to) { - $cachefilename='meteo.'.$sensor.'.'.$param.'.'.$from.'-'.$to.'.'.$img_format; + $cachefilename='meteo.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$from.'-'.$to.'.'.$img_format; } @@ -101,11 +117,15 @@ if ($type and $param) { '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' ); - $height = 60; + $bottomheight = 60; + $topheight = 40; + $sizex = 1000; + $sizey = 800; + $scale = True; } - $g = new Graph(640,480); + $g = new Graph($sizex,$sizey); if ($cachefilename) { if ($g->cache->IsValid($cachefilename)) { @@ -135,7 +155,7 @@ if ($type and $param) { $total_weight=0; $sum=0; - $maxdelta = 900; + $maxdelta = 1800; for ($j = $i; $j < count($xdata); ++$j) { @@ -167,34 +187,51 @@ if ($type and $param) { // Create the graph $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); + if ($scale) { + $g->xaxis->SetLabelAngle(90); + } else { + $g->xaxis->HideLabels(True); + } $g->xaxis->SetPos("min"); +# $g->xaxis->scale->SetTimeAlign( HOURADJ_1 ); + - // We use a scatterplot to illustrate the original - // contro points. - $splot = new ScatterPlot($ydata,$xdata); - $g->Add($splot); + if ($type!="last24small") { - // - $splot->mark->SetFillColor($dot_color); - $splot->mark->SetColor($dot_color); - $splot->mark->SetType(MARK_FILLEDCIRCLE); - $splot->mark->SetSize(2); + // We use a scatterplot to illustrate the original + // contro points. + $splot = new ScatterPlot($ydata,$xdata); + $g->Add($splot); + + // + $splot->mark->SetFillColor($dot_color); + $splot->mark->SetColor($dot_color); + $splot->mark->SetType(MARK_FILLEDCIRCLE); + $splot->mark->SetSize(2); + + } $fplot = new LinePlot($f_ydata,$xdata); $g->Add($fplot); $fplot->SetColor($line_color); $fplot->SetWeight(2); - $g->SetMargin(50,30,40,$height); - $g->title->Set($sensor_name.'/'.$param_name.', '.$param_unit); - $g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12); - $g->SetMarginColor('silver'); + $g->SetMargin(50,30,$topheight,$bottomheight); + if ($scale) { + $g->title->Set($sensor_name.'/'.$param_name.', '.$param_unit); + $g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12); + } + $g->SetMarginColor('lightgray'); + + $g->xgrid->Show(); + $g->xgrid->SetLineStyle('dotted'); + $g->ygrid->Show(); + $g->ygrid->SetLineStyle('dotted'); // Add the plots to the graph and stroke $g->Stroke();