The chart in the example consists of three mark lines (one horizontal and two vertical) and one vertical zone. The mark lines are created using
Axis.addMark. The zone is created using
Axis.addZone.
By default, mark labels will be drawn as axis labels. In this example, the label of the red mark line is moved to the top center of the mark line using
TextBox.setAlignment with
TopCenter alignment.
Similarly, the labels for the brown mark lines are moved to the left and right sides of the mark lines, with the text rotated by 90 degrees. This is achieved by using
TextBox.setAlignment with
Left and
Right alignments, and using
TextBox.setFontAngle.
[File: phpdemo/markzone2.php".]
setPlotArea(50, 25, 300, 200, 0xe0e0e0, 0xffffff, 0xc0c0c0, 0xc0c0c0,
0xc0c0c0);
#Add a title to the chart using 14 pts Times Bold Italic font
$c->addTitle("Server Monitor", "timesbi.ttf", 14);
#Add a title to the y axis
$c->yAxis->setTitle("Server Load (MBytes)");
#Set the y axis width to 2 pixels
$c->yAxis->setWidth(2);
#Set the labels on the x axis
$c->xAxis->setLabels($labels);
#Set the x axis width to 2 pixels
$c->xAxis->setWidth(2);
#Add a horizontal red (0x800080) mark line at y = 80
$yMark = $c->yAxis->addMark(80, 0xff0000, "Critical Threshold Set Point");
#Set the mark line width to 2 pixels
$yMark->setLineWidth(2);
#Put the mark label at the top center of the mark line
$yMark->setAlignment(TopCenter);
#Add an orange (0xffcc66) zone from x = 18 to x = 20
$c->xAxis->addZone(18, 20, 0xffcc66);
#Add a vertical brown (0x995500) mark line at x = 18
$xMark1 = $c->xAxis->addMark(18, 0x995500, "Backup Start");
#Set the mark line width to 2 pixels
$xMark1->setLineWidth(2);
#Put the mark label at the left of the mark line
$xMark1->setAlignment(Left);
#Rotate the mark label by 90 degrees so it draws vertically
$xMark1->setFontAngle(90);
#Add a vertical brown (0x995500) mark line at x = 20
$xMark2 = $c->xAxis->addMark(20, 0x995500, "Backup End");
#Set the mark line width to 2 pixels
$xMark2->setLineWidth(2);
#Put the mark label at the right of the mark line
$xMark2->setAlignment(Right);
#Rotate the mark label by 90 degrees so it draws vertically
$xMark2->setFontAngle(90);
#Add a green (0x00cc00) line layer with line width of 2 pixels
$lineLayerObj = $c->addLineLayer($data, 0xcc00);
$lineLayerObj->setLineWidth(2);
#output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?> |
© 2004 Advanced Software Engineering Limited. All rights reserved.