X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/3a48d89e76fd2ab87dabf08632474c529cf77ad4..d5653b977ce2b9d0ef6e6c07b3a9b64c1462e601:/web/image_minmax.php?ds=sidebyside diff --git a/web/image_minmax.php b/web/image_minmax.php deleted file mode 100644 index a0a6326..0000000 --- a/web/image_minmax.php +++ /dev/null @@ -1,192 +0,0 @@ - false)))) { - - die('Не могу подключиться к БД'); - -} - -$db -> exec('SET CHARACTER SET utf8'); - -$type = $_REQUEST['type']; -$sensor=$_REQUEST['sensor']; -$param=$_REQUEST['param']; -$year=$_REQUEST['year']; -$month=$_REQUEST['month']; - -if ($type and $param) { - - $sensor = intval($sensor); - $param = intval($param); - - $q = $db -> prepare( - 'select s_description from sensors where id='.$sensor - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $sensor_name = $row['s_description']; - } - - $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 -' - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_name = $row['st_description']; - $from_unit = $row['id']; - $unit_group = $row['unit_group']; - $fill_color_top=$row['st_fill_color_top']; - $fill_color_bottom=$row['st_fill_color_bottom']; - } - - if (!empty($_COOKIE['unit_'.$unit_group])) { - $to_unit=intval($_COOKIE['unit_'.$unit_group]); - } else { - $to_unit=$from_unit; - } - - $q = $db -> prepare( - 'select u.name_short from units u where u.id='.$to_unit - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_unit = $row['name_short']; - } - - $xdata = array(); - $ydata = array(); - - if ($type == 'month') { - - $next_year = $year; - $next_month = $month+1; - - if ($month==13) { - - $next_year++; - $month=1; - - } - - $q = $db -> prepare( - ' - select - x, - unitconv(min(value),'.$from_unit.','.$to_unit.') min_value, - unitconv(max(value),'.$from_unit.','.$to_unit.') max_value - from ( - select - unix_timestamp(cast(timestamp as date)) x, - value - from - sensor_values - where - timestamp>=str_to_date(\''.$year.$month.'\',\'%Y%m\') - and timestamp prepare( - ' - select - x, - unitconv(min(value),'.$from_unit.','.$to_unit.') min_value, - unitconv(max(value),'.$from_unit.','.$to_unit.') max_value - from ( - select - unix_timestamp( - DATE_SUB(cast(timestamp as date), INTERVAL DAYOFWEEK(cast(timestamp as date))-1 DAY) - ) x, - value - from - sensor_values - where - timestamp>=str_to_date(\''.$year.'\',\'%Y\') - and timestamp execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - $xdata[] = $row['x']; - $mindata[] = $row['min_value']; - $maxdata[] = $row['max_value']; - - } - - - // Create the graph - $g = new Graph(640,480); - $g->graph_theme = null; - - //$g->img->SetAntiAliasing(); - - // We need a linlin scale since we provide both - // x and y coordinates for the data points. - $g->SetScale('datlin'); - $g->xaxis->SetLabelAngle(90); - $g->xaxis->SetPos("min"); - - // 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->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->SetFillFromYMin(TRUE); - $aplot->SetWeight(4); - - $g->SetMargin(60,60,60,130); - $g->title->Set($sensor_name.'/'.$param_name.', '.$param_unit); - $g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12); - $g->subtitle->Set('(минимальные и максимальные значения за период)'); - $g->subtitle->SetColor('darkred'); - $g->SetMarginColor('silver'); - - // Add the plots to the graph and stroke - $g->Stroke(); - -} else { - - header("Content-Type: text/html; charset=UTF-8"); - die('Сенсор не выбран!'); - -} - -?> \ No newline at end of file