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