| 1 |
lars |
1 |
<?php
|
|
|
2 |
include ("../jpgraph.php");
|
|
|
3 |
include ("../jpgraph_bar.php");
|
|
|
4 |
|
|
|
5 |
$datay=array(12,8,19,3,10,5);
|
|
|
6 |
|
|
|
7 |
// Create the graph. These two calls are always required
|
|
|
8 |
$graph = new Graph(300,200,"auto");
|
|
|
9 |
$graph->SetScale("textlin");
|
|
|
10 |
|
|
|
11 |
// Add a drop shadow
|
|
|
12 |
$graph->SetShadow();
|
|
|
13 |
|
|
|
14 |
// Adjust the margin a bit to make more room for titles
|
|
|
15 |
$graph->img->SetMargin(40,30,20,40);
|
|
|
16 |
|
|
|
17 |
// Create a bar pot
|
|
|
18 |
$bplot = new BarPlot($datay);
|
|
|
19 |
$graph->Add($bplot);
|
|
|
20 |
|
|
|
21 |
// Create and add a new text
|
|
|
22 |
$txt=new Text("This is a text");
|
|
|
23 |
$txt->Pos(10,25);
|
|
|
24 |
$txt->SetFont(FF_FONT1,FS_BOLD);
|
|
|
25 |
$txt->SetBox('yellow','navy','gray');
|
|
|
26 |
$txt->SetColor("red");
|
|
|
27 |
$graph->AddText($txt);
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
// Setup the titles
|
|
|
31 |
$graph->title->Set("A simple bar graph");
|
|
|
32 |
$graph->xaxis->title->Set("X-title");
|
|
|
33 |
$graph->yaxis->title->Set("Y-title");
|
|
|
34 |
|
|
|
35 |
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
|
|
36 |
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
|
|
37 |
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
|
|
38 |
|
|
|
39 |
// Display the graph
|
|
|
40 |
$graph->Stroke();
|
|
|
41 |
?>
|