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(2,3,5,8,12,6,3); |
---|
6 | $datax=array("320x240","640x480","600x800","1024x768","1280x1024(16)","1280x1024(32)", |
---|
7 | "1600x1200(32)"); |
---|
8 | |
---|
9 | // Size of graph |
---|
10 | $width=300; |
---|
11 | $height=400; |
---|
12 | |
---|
13 | // Set the basic parameters of the graph |
---|
14 | $graph = new Graph($width,$height,'auto'); |
---|
15 | $graph->SetScale("textlin"); |
---|
16 | |
---|
17 | // No frame around the image |
---|
18 | $graph->SetFrame(false); |
---|
19 | |
---|
20 | // Rotate graph 90 degrees and set margin |
---|
21 | $graph->Set90AndMargin(100,20,50,30); |
---|
22 | |
---|
23 | // Set white margin color |
---|
24 | $graph->SetMarginColor('white'); |
---|
25 | |
---|
26 | // Use a box around the plot area |
---|
27 | $graph->SetBox(); |
---|
28 | |
---|
29 | // Use a gradient to fill the plot area |
---|
30 | $graph->SetBackgroundGradient('white','lightblue',GRAD_HOR,BGRAD_PLOT); |
---|
31 | |
---|
32 | // Setup title |
---|
33 | $graph->title->Set("Graphic card performance"); |
---|
34 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,11); |
---|
35 | $graph->subtitle->Set("(Non optimized)"); |
---|
36 | |
---|
37 | // Setup X-axis |
---|
38 | $graph->xaxis->SetTickLabels($datax); |
---|
39 | $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,8); |
---|
40 | |
---|
41 | // Some extra margin looks nicer |
---|
42 | $graph->xaxis->SetLabelMargin(10); |
---|
43 | |
---|
44 | // Label align for X-axis |
---|
45 | $graph->xaxis->SetLabelAlign('right','center'); |
---|
46 | |
---|
47 | // Add some grace to y-axis so the bars doesn't go |
---|
48 | // all the way to the end of the plot area |
---|
49 | $graph->yaxis->scale->SetGrace(20); |
---|
50 | |
---|
51 | // We don't want to display Y-axis |
---|
52 | $graph->yaxis->Hide(); |
---|
53 | |
---|
54 | // Now create a bar pot |
---|
55 | $bplot = new BarPlot($datay); |
---|
56 | $bplot->SetShadow(); |
---|
57 | |
---|
58 | //You can change the width of the bars if you like |
---|
59 | //$bplot->SetWidth(0.5); |
---|
60 | |
---|
61 | // Set gradient fill for bars |
---|
62 | $bplot->SetFillGradient('darkred','yellow',GRAD_HOR); |
---|
63 | |
---|
64 | // We want to display the value of each bar at the top |
---|
65 | $bplot->value->Show(); |
---|
66 | $bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
67 | //$bplot->value->SetAlign('left','center'); |
---|
68 | $bplot->value->SetColor("white"); |
---|
69 | $bplot->value->SetFormat('%.1f'); |
---|
70 | $bplot->SetValuePos('max'); |
---|
71 | |
---|
72 | // Add the bar to the graph |
---|
73 | $graph->Add($bplot); |
---|
74 | |
---|
75 | // Add some explanation text |
---|
76 | $txt = new Text('Note: Higher value is better.'); |
---|
77 | $txt->SetPos(190,399,'center','bottom'); |
---|
78 | $txt->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
79 | $graph->Add($txt); |
---|
80 | |
---|
81 | // .. and stroke the graph |
---|
82 | $graph->Stroke(); |
---|
83 | ?> |
---|