$xlegendpoint = ceil($i / $daypoint);
         $nb_day = date("d", $current_date);
         $x = ($xlegendpoint - $nb_day) * $daypoint;
         $x_label = date("M", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
         $image->setItemData($x, $x_label);
         for ($j = 1; $j <= 11; $j++) {
             $nb_day = date("t", mktime(0, 0, 0, date("m") - $j, date("d"), date("Y")));
             $x -= $nb_day * $daypoint;
             $x_label = date("M", mktime(0, 0, 0, date("m") - ($j + 1), date("d"), date("Y")));
             $image->setItemData($x, $x_label);
         }
         break;
 }
 $image->enable("ItemData");
 # Upper and lower indices and scale step
 $image->setY($upper_limit + 0.0001, 0, ceil($upper_limit / 5));
 #############################################################
 # How many data values do we have:
 # 24 hrs = 1440 min / collection interval ie.
 # 1440 / 15 mins = 96 values
 # I want to show legend only every 2 hours ie. 12 points
 #############################################################
 $image->paintXY();
 # Axis legend
 $image->paintScale("Time", "Number of licenses", "FF_FONT1");
 # Graph color
 $image->setGraphcolor(100, 100, 200);
 $image->paintData();
 ################################################################################
 # We will now draw a line that indicates the number of available licenses ie.
 # at the top of the graph we will draw a solid line
 # 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 {
     Header("Content-type: image/png");
 }