<?php
require_once("../lib/phpchartdir.php");
for ($i = 0; $i < 52; ++$i)
{
$data[$i] = $i + 10;
$labels[$i] = " ";
}
$daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
for ($i = 0; $i < 12; ++$i)
$weeksInMonth[$i] = $daysInMonth[$i] * 52 / 365;
# Create a XYChart object of size 250 x 250 pixels
$c = new XYChart(800, 250);
# Set the plotarea at (30, 20) and of size 200 x 200 pixels
$c->setPlotArea(50, 20, 720, 200);
# Add a bar chart layer using the given data
$c->addBarLayer($data);
# Set the labels on the x axis.
$c->xAxis->setLabels($labels);
$c->xAxis->setTickOffset(0.5);
$labelAxis = $c->addAxis(Bottom, 0);
$labelAxis->setLinearScale2(0, 51, array());
$labelAxis->setTickLength(10);
$monthNames = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
$xCoor = -0.5;
for ($i = 0; $i < 12; ++$i)
{
$labelAxis->addLabel($xCoor + $weeksInMonth[$i] / 2, "~" . $monthNames[$i]);
$xCoor += $weeksInMonth[$i];
$labelAxis->addLabel($xCoor, " ");
}
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>
|