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,8,19,3,10,5);
|
---|
6 |
|
---|
7 | // Create the graph. These two calls are always required
|
---|
8 | $graph = new Graph(300,200);
|
---|
9 | $graph->SetScale("textlin");
|
---|
10 |
|
---|
11 | // Add a drop shadow
|
---|
12 | $graph->SetShadow();
|
---|
13 |
|
---|
14 | // Adjust the margin a bit to make more room for titles
|
---|
15 | $graph->img->SetMargin(40,30,20,40);
|
---|
16 |
|
---|
17 | // Create a bar pot
|
---|
18 | $bplot = new BarPlot($datay);
|
---|
19 |
|
---|
20 | // Adjust fill color
|
---|
21 | $bplot->SetFillColor('orange');
|
---|
22 |
|
---|
23 | // Setup values
|
---|
24 | $bplot->value->Show();
|
---|
25 | $bplot->value->SetFormat('%d');
|
---|
26 | $bplot->value->SetFont(FF_FONT1,FS_BOLD);
|
---|
27 |
|
---|
28 | // Center the values in the bar
|
---|
29 | $bplot->SetValuePos('center');
|
---|
30 |
|
---|
31 | // Make the bar a little bit wider
|
---|
32 | $bplot->SetWidth(0.7);
|
---|
33 |
|
---|
34 | $graph->Add($bplot);
|
---|
35 |
|
---|
36 | // Setup the titles
|
---|
37 | $graph->title->Set("Centered values for bars");
|
---|
38 | $graph->xaxis->title->Set("X-title");
|
---|
39 | $graph->yaxis->title->Set("Y-title");
|
---|
40 |
|
---|
41 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
42 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
43 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
44 |
|
---|
45 | // Display the graph
|
---|
46 | $graph->Stroke();
|
---|
47 | ?>
|
---|