$data[$i] = 0; $i++; } } $j--; $recordset->free(); } #print_r($data); # Close the connection # If there is data in the set draw the graph if ($i > 1) { #$daypoint = 1440 / $collection_interval; $scalingfactor = $daypoint / $xlegendpoints; switch ($period) { case 'day': $image->setX($i + 1.0E-5, 0, 1); for ($j = 1; $j <= $xlegendpoints * 2; $j++) { $image->setItemData(1 + $j * $scalingfactor / 2, $j); # *2); } break; case 'week': # Use first letter format for X labels $image->setX($i + 1.0E-5, 0, $daypoint); $xlegendpoint = ceil($i / $daypoint); for ($j = 1; $j <= $xlegendpoint; $j++) { $axis_time = mktime(0, 0, 0, date("m"), date("d") - ($xlegendpoint - $j), date("Y")); $image->setItemData($j * $daypoint, date("D", $axis_time)); } break; case 'month':
$image->setItemData(0, 0); ################################################################### # There may be holes in usage stats ie. only 1 or 3 licenses are # used. We loop through the array. If there is no record we set # the value to zero ################################################################### for ($i = 0; $i <= $upper_limit; $i++) { if (isset($data[$i])) { $image->setData($i + 1, $data[$i]); } else { $image->setData($i + 1, 0); } $image->setItemData($i + 1, $i); } $image->enable("ItemData"); $image->setX($i + 1.0E-5, 0, ceil($upper_limit / 15)); # Upper and lower indices and scale step $image->setY(max($data) + 1.0E-5, 0, (int) (100 * max($data) / 5) / 100); # $image->paintXY(); # Axis legend $image->paintScale("Licenses used", "Time used in hours", 1); # Graph color $image->setGraphcolor(100, 200, 100); $image->paintData(); if (isset($_GET['debug'])) { print "SQL: " . $sql . "\n"; echo "If following array is empty your license utilization table is not\n being populated. Most common problem is that license_util.php script is not\n being run periodically ie. every 15 minutes.<p><PRE>"; print_r($image->m_data); exit; } else {