[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,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("(Department X)");
|
---|
| 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();
|
---|
| 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 mark graph with static lines
|
---|
| 44 | $graph->AddLine(new PlotLine(HORIZONTAL,0,"black",2));
|
---|
| 45 | $graph->AddLine(new PlotLine(VERTICAL,3,"black",2));
|
---|
| 46 |
|
---|
| 47 | //$graph->title->Set("Test of bar gradient fill");
|
---|
| 48 | $graph->xaxis->title->Set("X-title");
|
---|
| 49 | $graph->yaxis->title->Set("Y-title");
|
---|
| 50 |
|
---|
| 51 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,11);
|
---|
| 52 | $graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,11);
|
---|
| 53 |
|
---|
| 54 | $graph->Stroke();
|
---|
| 55 | ?>
|
---|