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; }
mysql_select_db('expenses'); $y = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // all values in this array has been assigned 0 so that if any null values arises then it will be saved as 0. for ($i = 1; $i < 13; $i++) { $query[$i] = "SELECT total FROM `unofficial` WHERE `date` BETWEEN '2013-{$i}-01' AND '2013-{$i}-31'"; // selects total from unofficial $t[$i] = mysql_query($query[$i]); $y[$i] = 0; while ($x[$i] = mysql_fetch_array($t[$i])) { $v[$i] = $x[$i]['total']; // storing values of total per month in an array $y[$i] = $y[$i] + $v[$i]; } } /* these set of statements forms the graph using phpMyGraph5.0.php API */ include_once 'phpMyGraph5.0.php'; header("Content-type: image/png"); $cfg['title'] = 'ExPENSES'; $cfg['width'] = 900; $cfg['height'] = 550; $cfg['column-color-random'] = 1; $cfg['jpg-quality'] = 600; $cfg['title-font-size'] = 6; $cfg['title-color'] = '#754719'; $cfg['key-color'] = '#OOOOOO'; $cfg['key-font-size'] = 6; $data = array('JAN' => $y[1], 'FEB' => $y[2], 'MAR' => $y[3], 'APR' => $y[4], 'MAY' => $y[5], 'JUN' => $y[6], 'JULY' => $y[7], 'AUG' => $y[8], 'SEP' => $y[9], 'OCT' => $y[10], 'NOV' => $y[11], 'DEC' => $y[12]); $graph = new phpMyGraph(); $graph->parseVerticalColumnGraph($data, $cfg);
$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); }
$cfg['height'] = 700; $cfg['title'] = "Past Month Visitor Count"; $cfg['column-color'] = "E23636"; unset($_SESSION['amounts']); break; case 2: $amounts = unserialize($_SESSION['amounts2']); $cfg['width'] = 600; $cfg['height'] = 300; $cfg['title'] = "Past Month Total Visitors / Pageviews"; unset($_SESSION['amounts2']); break; case 3: $amounts = unserialize($_SESSION['amounts3']); $cfg['width'] = 600; $cfg['height'] = 400; $cfg['title'] = "Past Month Top 10 Viewed Pages"; unset($_SESSION['amounts3']); break; default: $amounts = unserialize($_SESSION['amounts']); $cfg['width'] = 600; $cfg['height'] = 600; $cfg['title'] = $_SESSION['url']; unset($_SESSION['amounts']); } $cfg['column-color'] = "E23636"; header("Content-type: image/png"); include_once 'phpMyGraph5.0.php'; $graph = new phpMyGraph(); $graph->parseHorizontalColumnGraph($amounts, $cfg);
<?php header("content-type: image/png"); include_once "phpMyGraph5.0.php"; $cfg['title'] = "example"; $cfg['width'] = 500; $cfg['height'] = 250; $data = array(1955 => 12, 1945 => 25, 1965 => 29); $graph = new phpMyGraph(); $graph->parseHorizontalLineGraph($data, $cfg);