[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | |
---|
| 3 | require_once ('jpgraph/jpgraph.php'); |
---|
| 4 | require_once ('jpgraph/jpgraph_line.php'); |
---|
| 5 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
| 6 | |
---|
| 7 | // Some data |
---|
| 8 | |
---|
| 9 | $steps=100;for($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->img->SetMargin(40,180,40,40); |
---|
| 21 | $graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME); |
---|
| 22 | |
---|
| 23 | //$graph->img->SetAntiAliasing(); |
---|
| 24 | |
---|
| 25 | $graph->SetScale("intlin"); |
---|
| 26 | $graph->SetShadow(); |
---|
| 27 | $graph->title->Set("Combined bar and line plot"); |
---|
| 28 | $graph->subtitle->Set("(\"center\" aligned bars)"); |
---|
| 29 | |
---|
| 30 | // Use built in font |
---|
| 31 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
| 32 | |
---|
| 33 | // Slightly adjust the legend from it's default position in the |
---|
| 34 | // top right corner. |
---|
| 35 | $graph->legend->Pos(0.05,0.5,"right","center"); |
---|
| 36 | |
---|
| 37 | // Create the first line |
---|
| 38 | |
---|
| 39 | $p1 = new LinePlot($datay,$datax); |
---|
| 40 | $p1->SetWeight(1); |
---|
| 41 | $p1->SetColor("red"); |
---|
| 42 | $p1->SetLegend("Triumph Tiger -98"); |
---|
| 43 | $graph->Add($p1); |
---|
| 44 | |
---|
| 45 | $b1 = new BarPlot($databary,$databarx); |
---|
| 46 | $b1->SetAbsWidth(10); |
---|
| 47 | $b1->SetAlign("center"); |
---|
| 48 | $b1->SetShadow(); |
---|
| 49 | $graph->Add($b1); |
---|
| 50 | |
---|
| 51 | $graph->Stroke(); |
---|
| 52 | ?> |
---|