[42] | 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,5,19,22,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("Use of static line, 3D and solid band"); |
---|
| 17 | |
---|
| 18 | // Turn off Y-grid (it's on by default) |
---|
| 19 | $graph->ygrid->Show(false); |
---|
| 20 | |
---|
| 21 | // Add 10% grace ("space") at top of Y-scale. |
---|
| 22 | $graph->yscale->SetGrace(10); |
---|
| 23 | $graph->yscale->SetAutoMin(-20); |
---|
| 24 | |
---|
| 25 | // Turn the tick mark out from the plot area |
---|
| 26 | $graph->xaxis->SetTickSide(SIDE_DOWN); |
---|
| 27 | $graph->yaxis->SetTickSide(SIDE_LEFT); |
---|
| 28 | |
---|
| 29 | // Create a bar pot |
---|
| 30 | $bplot = new BarPlot($datay); |
---|
| 31 | $bplot->SetFillColor("orange"); |
---|
| 32 | $bplot->SetShadow("darkblue"); |
---|
| 33 | |
---|
| 34 | // Show the actual value for each bar on top/bottom |
---|
| 35 | $bplot->value->Show(true); |
---|
| 36 | $bplot->value->SetFormat("%02d kr"); |
---|
| 37 | |
---|
| 38 | // Position the X-axis at the bottom of the plotare |
---|
| 39 | $graph->xaxis->SetPos("min"); |
---|
| 40 | |
---|
| 41 | // .. and add the plot to the graph |
---|
| 42 | $graph->Add($bplot); |
---|
| 43 | |
---|
| 44 | // Add upper and lower band and use no frames |
---|
| 45 | $band[0]=new PlotBand(HORIZONTAL,BAND_3DPLANE,"min",0,"blue"); |
---|
| 46 | $band[0]->ShowFrame(false); |
---|
| 47 | $band[0]->SetDensity(20); |
---|
| 48 | $band[1]=new PlotBand(HORIZONTAL,BAND_SOLID,0,"max","steelblue"); |
---|
| 49 | $band[1]->ShowFrame(false); |
---|
| 50 | $graph->Add($band); |
---|
| 51 | |
---|
| 52 | $graph->Add(new PlotLine(HORIZONTAL,0,"black",2)); |
---|
| 53 | |
---|
| 54 | //$graph->title->Set("Test of bar gradient fill"); |
---|
| 55 | $graph->xaxis->title->Set("X-title"); |
---|
| 56 | $graph->yaxis->title->Set("Y-title"); |
---|
| 57 | |
---|
| 58 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
| 59 | $graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
| 60 | |
---|
| 61 | $graph->Stroke(); |
---|
| 62 | ?> |
---|