header('Content-Type: application/javascript');
require '../includes/_func.php';
require '../includes/config.inc.php';
$data_labels = "";
$data_dates = "";
$result = query("select DATE_FORMAT(date, '%Y-%m') as date,ROUND(AVG(light),2) as light from #day where YEAR(date) = YEAR(NOW()) group by MONTH(date) order by date", $check);
$data_light = "";
$light_min = null;
$light_max = null;
for ($j = 1; $j <= 12; $j++) {
    //label
    $data_labels .= '"' . mesic_nazev($j) . '"' . ($j < 12 ? ', ' : '');
    //Data dates
    $data_dates .= '"' . mesic_nazev($j) . date(" Y") . '"' . ($j < 12 ? ', ' : '');
    //Data
    $search = searchForDate(date("Y-") . ($j < 10 ? '0' : '') . $j, $result);
    $data_light .= (!is_null($search) ? '"' . $result[$search]['light'] . '"' : '') . ($j > 0 ? ', ' : '');
    if (!is_null($search)) {
        if (is_null($light_min)) {
            $light_min = $result[$search]['light'];
        }
        if (is_null($light_max)) {
            $light_max = $result[$search]['light'];
        }
        if ($result[$search]['light'] < $light_min) {
            $light_min = $result[$search]['light'];
        }
        if ($result[$search]['light'] > $light_max) {
            $light_max = $result[$search]['light'];
        }
    }
Example #2
0
$data_labels = "";
for ($j = 23; $j >= 0; $j--) {
    $cas = date("H") - $j;
    if ($cas < 0) {
        $cas = 24 + $cas;
    }
    $data_labels .= '"' . $cas . ':00"' . ($j > 0 ? ', ' : '');
}
//data
$result = query("select date,ROUND(light,2) as light from #hour where date > DATE_SUB(NOW() , INTERVAL 1 DAY) order by date", $check);
$data_light = "";
$light_min = null;
$light_max = null;
for ($j = 23; $j >= 0; $j--) {
    $den = date("Y-m-d H", time() - 60 * 60 * $j);
    $search = searchForDate($den, $result);
    $data_light .= (!is_null($search) ? '"' . $result[$search]['light'] . '"' : '') . ($j > 0 ? ', ' : '');
    if (!is_null($search)) {
        if (is_null($light_min)) {
            $light_min = $result[$search]['light'];
        }
        if (is_null($light_max)) {
            $light_max = $result[$search]['light'];
        }
        if ($result[$search]['light'] < $light_min) {
            $light_min = $result[$search]['light'];
        }
        if ($result[$search]['light'] > $light_max) {
            $light_max = $result[$search]['light'];
        }
    }
require '../includes/config.inc.php';
$data_labels = "";
$data_dates = "";
$result = query("select DATE_FORMAT(date, '%Y') as date,ROUND(AVG(light),2) as light from #day where YEAR(date) = YEAR(NOW()) group by YEAR(date) order by date", $check);
$data_light = "";
$light_min = null;
$light_max = null;
$firstYear = date("Y", strtotime($result[0]['date']));
$lastYear = date("Y", strtotime($result[count($result) - 1]['date']));
for ($j = $firstYear; $j <= $lastYear; $j++) {
    //label
    $data_labels .= '"' . $j . '"' . ($j < $lastYear ? ', ' : '');
    //Data dates
    $data_dates .= '"rok ' . $j . '"' . ($j < $lastYear ? ', ' : '');
    //Data
    $search = searchForDate($j, $result);
    $data_light .= (!is_null($search) ? '"' . $result[$search]['light'] . '"' : '') . ($j < $lastYear ? ', ' : '');
    if (!is_null($search)) {
        if (is_null($light_min)) {
            $light_min = $result[$search]['light'];
        }
        if (is_null($light_max)) {
            $light_max = $result[$search]['light'];
        }
        if ($result[$search]['light'] < $light_min) {
            $light_min = $result[$search]['light'];
        }
        if ($result[$search]['light'] > $light_max) {
            $light_max = $result[$search]['light'];
        }
    }