[42] | 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,40,40);
|
---|
| 10 | $graph->SetScale("textlin");
|
---|
| 11 | $graph->SetShadow();
|
---|
| 12 |
|
---|
| 13 | // Create a bar pot
|
---|
| 14 | $bplot = new BarPlot($datay);
|
---|
| 15 | $bplot->SetFillColor("orange");
|
---|
| 16 |
|
---|
| 17 | // DIsplay value at top of each bar
|
---|
| 18 | $bplot->value->Show();
|
---|
| 19 | $bplot->SetShadow();
|
---|
| 20 |
|
---|
| 21 | $graph->Add($bplot);
|
---|
| 22 |
|
---|
| 23 | // Position the scale at the min of the other axis
|
---|
| 24 | $graph->xaxis->SetPos("min");
|
---|
| 25 |
|
---|
| 26 | // Add 10% more space at top and bottom of graph
|
---|
| 27 | $graph->yscale->SetGrace(10,10);
|
---|
| 28 |
|
---|
| 29 | $graph->xaxis->title->Set("X-title");
|
---|
| 30 | $graph->yaxis->title->Set("Y-title");
|
---|
| 31 |
|
---|
| 32 | $graph->title->SetFont(FF_VERDANA,FS_NORMAL,12);
|
---|
| 33 | $graph->title->Set("Example of bar plot with absolute labels");
|
---|
| 34 |
|
---|
| 35 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_NORMAL,16);
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | $graph->Stroke();
|
---|
| 39 | ?>
|
---|