1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
4 | |
---|
5 | $datay=array(12,0,-19,-7,17,-6); |
---|
6 | |
---|
7 | // Create the graph. |
---|
8 | $graph = new Graph(400,300); |
---|
9 | $graph->img->SetMargin(60,30,50,40); |
---|
10 | $graph->SetScale("textlin"); |
---|
11 | $graph->SetShadow(); |
---|
12 | |
---|
13 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,15); |
---|
14 | $graph->title->Set("Cash flow "); |
---|
15 | $graph->subtitle->Set("(Department X)"); |
---|
16 | |
---|
17 | // Show both X and Y grid |
---|
18 | $graph->xgrid->Show(true,false); |
---|
19 | |
---|
20 | // Add 10% grace ("space") at top and botton of Y-scale. |
---|
21 | $graph->yscale->SetGrace(10,10); |
---|
22 | |
---|
23 | // Turn the tick mark out from the plot area |
---|
24 | $graph->xaxis->SetTickSide(SIDE_DOWN); |
---|
25 | $graph->yaxis->SetTickSide(SIDE_LEFT); |
---|
26 | |
---|
27 | // Create a bar pot |
---|
28 | $bplot = new BarPlot($datay); |
---|
29 | $bplot->SetFillColor("orange"); |
---|
30 | |
---|
31 | // Show the actual value for each bar on top/bottom |
---|
32 | $bplot->value->Show(true); |
---|
33 | $bplot->value->SetFormat("%02d kr"); |
---|
34 | |
---|
35 | // Position the X-axis at the bottom of the plotare |
---|
36 | $graph->xaxis->SetPos("min"); |
---|
37 | |
---|
38 | // .. and add the plot to the graph |
---|
39 | $graph->Add($bplot); |
---|
40 | |
---|
41 | // Add upper and lower band and use no frames |
---|
42 | $uband=new PlotBand(HORIZONTAL,BAND_RDIAG,0,"max","green"); |
---|
43 | $uband->ShowFrame(false); |
---|
44 | $uband->SetDensity(50); // 50% line density |
---|
45 | $lband=new PlotBand(HORIZONTAL,BAND_LDIAG,"min",0,"red"); |
---|
46 | $lband->ShowFrame(false); |
---|
47 | $lband->SetDensity(20); // 20% line density |
---|
48 | |
---|
49 | $graph->Add($uband); |
---|
50 | $graph->Add($lband); |
---|
51 | |
---|
52 | //$graph->title->Set("Test of bar gradient fill"); |
---|
53 | $graph->xaxis->title->Set("X-title"); |
---|
54 | $graph->yaxis->title->Set("Y-title"); |
---|
55 | |
---|
56 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
57 | $graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
58 | |
---|
59 | $graph->Stroke(); |
---|
60 | ?> |
---|