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