This example demonstrates using multiple data sets to create stacked area chart. The followings are key features of this example:
[File: phpdemo/stackedarea.php".]
setPlotArea(50, 30, 240, 140);
$plotAreaObj->setBackground(0xffffff);
#Add a legend box at (50, 185) (below of plot area) using horizontal layout. Use
#8 pts Arial font with Transparent background.
$legendObj = $c->addLegend(50, 185, false, "", 8);
$legendObj->setBackground(Transparent);
#Add a title box to the chart using 8 pts Arial Bold font, with yellow
#(0xffff40) background and a black border (0x0)
$titleObj = $c->addTitle("Sales Volume", "arialbd.ttf", 8);
$titleObj->setBackground(0xffff40, 0);
#Set the y axis label format to US$nnnn
$c->yAxis->setLabelFormat("US\${value}");
#Set the x axis labels using the given labels
$c->xAxis->setLabels($labels);
#Add an stack area layer with three data sets
$layer = $c->addAreaLayer2(Stack);
$layer->addDataSet($data0, 0x4040ff, "Store #1");
$layer->addDataSet($data1, 0xff4040, "Store #2");
$layer->addDataSet($data2, 0x40ff40, "Store #3");
#output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?> |
© 2004 Advanced Software Engineering Limited. All rights reserved.