}
$q = $db -> prepare(
- 'select st.st_fill_color_top,st.st_fill_color_bottom,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id
-'
+ 'select st.st_fill_color_top,st.st_fill_color_bottom,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id'
);
$q -> execute();
$next_year = $year;
$next_month = $month+1;
- if ($month==13) {
+ if ($month==12) {
$next_year++;
$next_month=1;
-
+
}
$curr = date("Ym");
+ $ym=sprintf('%04d%02d',$next_year,$next_month);
- if ($curr>$next_year.$next_month) {
+ if ($curr>$ym) {
- $cachefilename='meteo.month.'.$sensor.'.'.$param.'.'.$year.'-'.$month.'.'.$img_format;
+ $cachefilename='meteo.month.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$year.'-'.$month.'.'.$img_format;
}
+ $datestr=sprintf("%04d%02d01",$year,$month);
+ $nextdatestr=sprintf("%04d%02d01",$next_year,$next_month);
+
$q = $db -> prepare(
- '
+ '
select
x,
unitconv(min(min),'.$from_unit.','.$to_unit.') min_value,
from
sensors_ranges
where
- day>=str_to_date(\''.$year.$month.'\',\'%Y%m\')
- and day<str_to_date(\''.$next_year.$next_month.'\',\'%Y%m\')
+ day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\')
+ and day<STR_TO_DATE(\''.$nextdatestr.'\',\'%Y%m%d\')
and sensor='.$sensor.'
and parameter='.$param.'
) t group by x
order by x'
);
-
+
} elseif ($type == "year") {
$next_year = $year+1;
}
+ $datestr=sprintf("%04d0101",$year);
+ $nextdatestr=sprintf("%04d0101",$next_year);
+
$q = $db -> prepare(
'
select
from
sensors_ranges
where
- day>=str_to_date(\''.$year.'\',\'%Y\')
- and day<str_to_date(\''.$next_year.'\',\'%Y\')
+ day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\')
+ and day<STR_TO_DATE(\''.$nextdatestr.'\',\'%Y%m%d\')
and sensor='.$sensor.'
and parameter='.$param.'
) t group by x
}
-
// Create the graph
$g->graph_theme = null;
$g->SetScale('datlin');
$g->xaxis->SetLabelAngle(90);
$g->xaxis->SetPos("min");
+ $g->xaxis->scale->SetTimeAlign( MINADJ_1 );
// We use a scatterplot to illustrate the original
// contro points.
$bplot = new LinePlot($maxdata,$xdata);
$g->Add($bplot);
$bplot->SetColor($fill_color_top);
- $bplot->SetFillGradient($fill_color_top,$fill_color_bottom,100,TRUE);
+ $bplot->SetFillGradient($fill_color_top.'@0.2',$fill_color_bottom.'@0.9',100,TRUE);
$bplot->SetFillFromYMin(TRUE);
$bplot->SetWeight(4);
$aplot = new LinePlot($mindata,$xdata);
$g->Add($aplot);
$aplot->SetColor($fill_color_bottom);
- $aplot->SetFillGradient($fill_color_bottom,'white',100,TRUE);
+ $aplot->SetFillGradient($fill_color_bottom.'@0.2','white@0.9',100,TRUE);
$aplot->SetFillFromYMin(TRUE);
$aplot->SetWeight(4);
$g->subtitle->SetColor('darkred');
$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();