source: trunk/xgraph/jpgraph/Examples/linebarex2.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.4 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4require_once ('jpgraph/jpgraph_bar.php');
5
6// Some data
7
8$steps=100;
9for($i=0; $i<$steps; ++$i) {
10        $datay[$i]=log(pow($i,$i/10)+1)*sin($i/15)+35;
11        $datax[]=$i;
12        if( $i % 10 == 0 ) {
13                $databarx[]=$i;
14                $databary[]=$datay[$i]/2;
15        }
16}
17
18// New graph with a background image and drop shadow
19$graph = new Graph(450,300);
20$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);
21$graph->SetShadow();
22
23// Use an integer X-scale
24$graph->SetScale("intlin");
25
26// Set title and subtitle
27$graph->title->Set("Combined bar and line plot");
28$graph->subtitle->Set("(\"left\" aligned bars)");
29
30// Use built in font
31$graph->title->SetFont(FF_FONT1,FS_BOLD);
32
33// Make the margin around the plot a little bit bigger
34// then default
35$graph->img->SetMargin(40,120,40,40);   
36
37// Slightly adjust the legend from it's default position in the
38// top right corner to middle right side
39$graph->legend->Pos(0.05,0.5,"right","center");
40
41// Create a red line plot
42$p1 = new LinePlot($datay,$datax);
43$p1->SetColor("red");
44$p1->SetLegend("Status one");
45$graph->Add($p1);
46
47// Create the bar plot
48$b1 = new BarPlot($databary,$databarx);
49$b1->SetLegend("Status two");
50$b1->SetAlign("left");
51$b1->SetShadow();
52$graph->Add($b1);
53
54// Finally output the  image
55$graph->Stroke();
56
57?>
58
59
Note: See TracBrowser for help on using the repository browser.