<?php
require_once("../lib/phpchartdir.php");
# The data for the line chart
$data0 = array(50, 55, 47, 36, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
59, 73, 77, 84, 82, 80, 84);
$data1 = array(36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 36, 30, 45, 46,
42, 48, 45, 43, 52, 64, 70);
# The labels for the line chart
$labels = array("Jan-04", "Feb-04", "Mar-04", "Apr-04", "May-04", "Jun-04", "Jul-04",
"Aug-04", "Sep-04", "Oct-04", "Nov-04", "Dec-04", "Jan-05", "Feb-05", "Mar-05",
"Apr-05", "May-05", "Jun-05", "Jul-05", "Aug-05", "Sep-05", "Oct-05", "Nov-05",
"Dec-05");
# Create an XYChart object of size 600 x 360 pixels, with a light blue (EEEEFF)
# background, black border, 1 pxiel 3D border effect and rounded corners
$c = new XYChart(600, 360, 0xeeeeff, 0x000000, 1);
$c->setRoundedFrame();
# Set plotarea at (55, 60) with size of 520 x 240 pixels. Use white (ffffff) as
# background and grey (cccccc) for grid lines
$c->setPlotArea(55, 60, 520, 240, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
# Add a legend box at (55, 58) (top of plot area) using 9 pts Arial Bold font with
# horizontal layout Set border and background colors of the legend box to Transparent
$legendBox = $c->addLegend(55, 58, false, "arialbd.ttf", 9);
$legendBox->setBackground(Transparent);
# Reserve 10% margin at the top of the plot area during auto-scaling to leave space
# for the legends.
$c->yAxis->setAutoScale(0.1);
# Add a title to the chart using 15 pts Times Bold Italic font. The text is white
# (ffffff) on a blue (0000cc) background, with glass effect.
$title = $c->addTitle("Monthly Revenue for Year 2000/2001", "timesbi.ttf", 15,
0xffffff);
$title->setBackground(0x0000cc, 0x000000, glassEffect(ReducedGlare));
# Add a title to the y axis
$c->yAxis->setTitle("Month Revenue (USD millions)");
# Set the labels on the x axis. Draw the labels vertical (angle = 90)
$labelsObj = $c->xAxis->setLabels($labels);
$labelsObj->setFontAngle(90);
# Add the data sets to the line layer
$c->addLineLayer($data0, 0xff00ff, "Enterprise");
$c->addLineLayer($data1, 0x00ff00, "Consumer");
$highLight = isset($_GET["highLight"]) ? (int)($_GET["highLight"]) : 0;
$layer = $c->getLayer($highLight);
$layer->moveFront();
$layer->setLineWidth(3);
if (isset($_GET["highLight"])) {
header("Content-type: image/png");
print($c->makeChart2(PNG));
exit();
}
# Create the image
$chart1URL = $c->makeSession("chart1");
# Create an image map for the chart
$chartImageMap = $c->getHTMLImageMap("xystub.php", "",
"title='{dataSetName} @ {xLabel} = USD {value|0} millions'");
# Create an image map for the legend box
$legendImageMap = $legendBox->getHTMLImageMap("", "", "onmouseover='streamChart({layerId})'");
?>
<html>
<body style="margin:5px 0px 0px 5px">
<script type="text/javascript">
var currentChart = "";
function streamChart(id) {
document.getElementById("myChart").src = "?highLight=" + id;
}
</script>
<img id="myChart" src="getchart.php?<?php echo $chart1URL?>" border="0" usemap="#map1">
<map name="map1">
<?php echo $chartImageMap?>
<?php echo $legendImageMap?>
</map>
</body>
</html>
|