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

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.3 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_bar.php');
4
5$datay=array(20,30,50,80);
6$datay2=array(430,645,223,690);
7$datazero=array(0,0,0,0);
8
9// Create the graph.
10$graph = new Graph(450,200);
11$graph->title->Set('Example with 2 scale bars');
12
13// Setup Y and Y2 scales with some "grace"     
14$graph->SetScale("textlin");
15$graph->SetY2Scale("lin");
16$graph->yaxis->scale->SetGrace(30);
17$graph->y2axis->scale->SetGrace(30);
18
19//$graph->ygrid->Show(true,true);
20$graph->ygrid->SetColor('gray','lightgray@0.5');
21
22// Setup graph colors
23$graph->SetMarginColor('white');
24$graph->y2axis->SetColor('darkred');
25
26
27// Create the "dummy" 0 bplot
28$bplotzero = new BarPlot($datazero);
29
30// Create the "Y" axis group
31$ybplot1 = new BarPlot($datay);
32$ybplot1->value->Show();
33$ybplot = new GroupBarPlot(array($ybplot1,$bplotzero));
34
35// Create the "Y2" axis group
36$ybplot2 = new BarPlot($datay2);
37$ybplot2->value->Show();
38$ybplot2->value->SetColor('darkred');
39$ybplot2->SetFillColor('darkred');
40$y2bplot = new GroupBarPlot(array($bplotzero,$ybplot2));
41
42// Add the grouped bar plots to the graph
43$graph->Add($ybplot);
44$graph->AddY2($y2bplot);
45
46// .. and finally stroke the image back to browser
47$graph->Stroke();
48?>
Note: See TracBrowser for help on using the repository browser.