1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | // $Id: barintex1.php,v 1.3 2002/07/11 23:27:28 aditus Exp $ |
---|
3 | require_once ('jpgraph/jpgraph.php'); |
---|
4 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
5 | |
---|
6 | // Some data |
---|
7 | $datay=array(1,1,0.5); |
---|
8 | |
---|
9 | // Create the graph and setup the basic parameters |
---|
10 | $graph = new Graph(460,200,'auto'); |
---|
11 | $graph->img->SetMargin(40,30,30,40); |
---|
12 | $graph->SetScale("textint"); |
---|
13 | $graph->SetShadow(); |
---|
14 | $graph->SetFrame(false); // No border around the graph |
---|
15 | |
---|
16 | // Add some grace to the top so that the scale doesn't |
---|
17 | // end exactly at the max value. |
---|
18 | $graph->yaxis->scale->SetGrace(100); |
---|
19 | |
---|
20 | // Setup X-axis labels |
---|
21 | $a = $gDateLocale->GetShortMonth(); |
---|
22 | $graph->xaxis->SetTickLabels($a); |
---|
23 | $graph->xaxis->SetFont(FF_FONT2); |
---|
24 | |
---|
25 | // Setup graph title ands fonts |
---|
26 | $graph->title->Set("Example of integer Y-scale"); |
---|
27 | $graph->title->SetFont(FF_FONT2,FS_BOLD); |
---|
28 | $graph->xaxis->title->Set("Year 2002"); |
---|
29 | $graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD); |
---|
30 | |
---|
31 | // Create a bar pot |
---|
32 | $bplot = new BarPlot($datay); |
---|
33 | $bplot->SetFillColor("orange"); |
---|
34 | $bplot->SetWidth(0.5); |
---|
35 | $bplot->SetShadow(); |
---|
36 | |
---|
37 | // Setup the values that are displayed on top of each bar |
---|
38 | $bplot->value->Show(); |
---|
39 | // Must use TTF fonts if we want text at an arbitrary angle |
---|
40 | $bplot->value->SetFont(FF_ARIAL,FS_BOLD); |
---|
41 | $bplot->value->SetAngle(45); |
---|
42 | // Black color for positive values and darkred for negative values |
---|
43 | $bplot->value->SetColor("black","darkred"); |
---|
44 | $graph->Add($bplot); |
---|
45 | |
---|
46 | // Finally stroke the graph |
---|
47 | $graph->Stroke(); |
---|
48 | ?> |
---|