Line | |
---|
1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
4 | |
---|
5 | // Some data |
---|
6 | for($i=0; $i < 12; ++$i) { |
---|
7 | $databary[$i] = rand(1,20); |
---|
8 | } |
---|
9 | $months=$gDateLocale->GetShortMonth(); |
---|
10 | |
---|
11 | // New graph with a drop shadow |
---|
12 | $graph = new Graph(300,200); |
---|
13 | $graph->SetShadow(); |
---|
14 | |
---|
15 | // Use a "text" X-scale |
---|
16 | $graph->SetScale('textlin'); |
---|
17 | |
---|
18 | // Specify X-labels |
---|
19 | $graph->xaxis->SetTickLabels($months); |
---|
20 | $graph->xaxis->SetTextLabelInterval(2); |
---|
21 | |
---|
22 | // Set title and subtitle |
---|
23 | $graph->title->Set('Textscale with tickinterval=2'); |
---|
24 | |
---|
25 | // Use built in font |
---|
26 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
27 | |
---|
28 | // Create the bar plot |
---|
29 | $b1 = new BarPlot($databary); |
---|
30 | $b1->SetLegend('Temperature'); |
---|
31 | |
---|
32 | // The order the plots are added determines who's ontop |
---|
33 | $graph->Add($b1); |
---|
34 | |
---|
35 | // Finally output the image |
---|
36 | $graph->Stroke(); |
---|
37 | |
---|
38 | ?> |
---|
39 | |
---|
40 | |
---|
Note: See
TracBrowser
for help on using the repository browser.