This example demonstrates using symbols to represent data points, and putting data labels on top of the symbols.
Note that this example uses a 1 x 2 pixel pattern as the title background.
[File: phpdemo/symbolline.php".]
setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, 0xc0c0c0, -1);
#Add a legend box at (45, 12) (top of the chart) using horizontal layout and 8
#pts Arial font Set the background and border color to Transparent.
$legendObj = $c->addLegend(45, 12, false, "", 8);
$legendObj->setBackground(Transparent);
#Add a title to the chart using 9 pts Arial Bold/white font. Use a 1 x 2 bitmap
#pattern as the background.
$titleObj = $c->addTitle("Server Load (Jun 01 - Jun 07)", "arialbd.ttf", 9,
0xffffff);
$titleObj->setBackground($c->patternColor(array(0x4000, 0x8000), 2));
#Set the y axis label format to nn%
$c->yAxis->setLabelFormat("{value}%");
#Set the labels on the x axis
$c->xAxis->setLabels($labels);
#Add a line layer to the chart
$layer = $c->addLineLayer();
#Add the first line. Plot the points with a 7 pixel square symbol
$dataSetObj = $layer->addDataSet($data0, 0xcf4040, "Peak");
$dataSetObj->setDataSymbol(SquareSymbol, 7);
#Add the second line. Plot the points with a 9 pixel dismond symbol
$dataSetObj = $layer->addDataSet($data1, 0x40cf40, "Average");
$dataSetObj->setDataSymbol(DiamondSymbol, 9);
#Enable data label on the data points. Set the label format to nn%.
$layer->setDataLabelFormat("{value|0}%");
#output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?> |
© 2004 Advanced Software Engineering Limited. All rights reserved.