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 | $months=$gDateLocale->GetShortMonth(); |
---|
7 | srand ((double) microtime() * 1000000); |
---|
8 | for( $i=0; $i<25; ++$i) { |
---|
9 | $databary[]=rand(1,50); |
---|
10 | $databarx[]=$months[$i%12]; |
---|
11 | } |
---|
12 | |
---|
13 | // New graph with a drop shadow |
---|
14 | $graph = new Graph(300,200,'auto'); |
---|
15 | $graph->SetShadow(); |
---|
16 | |
---|
17 | // Use a "text" X-scale |
---|
18 | $graph->SetScale("textlin"); |
---|
19 | |
---|
20 | // Specify X-labels |
---|
21 | $graph->xaxis->SetTickLabels($databarx); |
---|
22 | $graph->xaxis->SetTextLabelInterval(3); |
---|
23 | |
---|
24 | // Hide the tick marks |
---|
25 | $graph->xaxis->HideTicks(); |
---|
26 | |
---|
27 | // Set title and subtitle |
---|
28 | $graph->title->Set("Bar tutorial example 6"); |
---|
29 | |
---|
30 | // Use built in font |
---|
31 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
32 | |
---|
33 | // Create the bar plot |
---|
34 | $b1 = new BarPlot($databary); |
---|
35 | $b1->SetLegend("Temperature"); |
---|
36 | $b1->SetWidth(0.4); |
---|
37 | |
---|
38 | |
---|
39 | // The order the plots are added determines who's ontop |
---|
40 | $graph->Add($b1); |
---|
41 | |
---|
42 | // Finally output the image |
---|
43 | $graph->Stroke(); |
---|
44 | |
---|
45 | ?> |
---|
46 | |
---|
47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.