Exemplo n.º 1
0
 public static function createGraphicalBurndownChart($bible, $year, $month)
 {
     // Number of days in the month for on the X-axis.
     $time = mktime(0, 0, 0, $month, 15, $year);
     $days_in_month = date("t", $time);
     // Assemble history of this sprint.
     $database_sprint = Database_Sprint::getInstance();
     $history = $database_sprint->getHistory($bible, $year, $month);
     $data = array();
     for ($day = 1; $day <= $days_in_month; $day++) {
         foreach ($history as $item) {
             if ($day == $item['day']) {
                 $tasks = $item['tasks'];
                 $complete = $item['complete'];
                 $tasks = $tasks * (100 - $complete) / 100;
                 $tasks = intval($tasks);
                 $data[$day] = $tasks;
             }
         }
     }
     // Create burndown chart as an image.
     include_once "../phpmygraph/phpMyGraph5.0.php";
     $cfg['title-visible'] = false;
     $cfg['width'] = 700;
     $cfg['height'] = 250;
     $cfg['zero-line-visible'] = false;
     $cfg['average-line-visible'] = false;
     $cfg['round-value-range'] = true;
     ob_start();
     $graph = new phpMyGraph();
     $graph->parseVerticalLineGraph($data, $cfg);
     $image = ob_get_contents();
     ob_end_clean();
     return $image;
 }
    $index = "";
    // Geforderte Daten einlesen und in Array aufbereiten
    while ($row = mysql_fetch_array($result)) {
        $val = averageValue($val, $row['value']);
        if ($i % $chkNr == 0) {
            if ($lastDay != $row['tag']) {
                $lastDay = $row['tag'];
                $index = $row['tag'] . " " . $row['zeit'];
            } else {
                $index = $row['zeit'];
            }
            $data[$index] = $val;
        }
        $i++;
    }
    mysql_close($link);
    // Create phpMyGraph instance
    $graph = new phpMyGraph();
    $graph->parseVerticalLineGraph($data, $cfg);
} else {
    exit("Parameter: sensorId  muss eingegeben werden");
}
function averageValue($average, $newVal)
{
    if ($average == 0) {
        $average = $newVal;
    } else {
        $average = ($average + $newVal) / 2;
    }
    return floor($average);
}