[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | |
---|
| 3 | require_once ('jpgraph/jpgraph.php'); |
---|
| 4 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
| 5 | require_once ('jpgraph/jpgraph_flags.php'); |
---|
| 6 | |
---|
| 7 | // Some data |
---|
| 8 | $datay1=array(140,110,50); |
---|
| 9 | $datay2=array(35,90,190); |
---|
| 10 | $datay3=array(20,60,70); |
---|
| 11 | |
---|
| 12 | // Create the basic graph |
---|
| 13 | $graph = new Graph(300,200); |
---|
| 14 | $graph->SetScale('textlin'); |
---|
| 15 | $graph->SetMargin(40,20,20,40); |
---|
| 16 | $graph->SetMarginColor('white:0.9'); |
---|
| 17 | $graph->SetColor('white'); |
---|
| 18 | $graph->SetShadow(); |
---|
| 19 | |
---|
| 20 | // Adjust the position of the legend box |
---|
| 21 | $graph->legend->Pos(0.03,0.10); |
---|
| 22 | |
---|
| 23 | // Adjust the color for theshadow of the legend |
---|
| 24 | $graph->legend->SetShadow('darkgray@0.5'); |
---|
| 25 | $graph->legend->SetFillColor('lightblue@0.1'); |
---|
| 26 | $graph->legend->Hide(); |
---|
| 27 | |
---|
| 28 | // Get localised version of the month names |
---|
| 29 | $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); |
---|
| 30 | $graph->SetBackgroundCountryFlag('mais',BGIMG_COPY,50); |
---|
| 31 | |
---|
| 32 | // Set axis titles and fonts |
---|
| 33 | $graph->xaxis->title->Set('Year 2002'); |
---|
| 34 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
| 35 | $graph->xaxis->title->SetColor('white'); |
---|
| 36 | |
---|
| 37 | $graph->xaxis->SetFont(FF_FONT1,FS_BOLD); |
---|
| 38 | $graph->xaxis->SetColor('navy'); |
---|
| 39 | |
---|
| 40 | $graph->yaxis->SetFont(FF_FONT1,FS_BOLD); |
---|
| 41 | $graph->yaxis->SetColor('navy'); |
---|
| 42 | |
---|
| 43 | //$graph->ygrid->Show(false); |
---|
| 44 | $graph->ygrid->SetColor('white@0.5'); |
---|
| 45 | |
---|
| 46 | // Setup graph title |
---|
| 47 | $graph->title->Set('Using a country flag background'); |
---|
| 48 | |
---|
| 49 | // Some extra margin (from the top) |
---|
| 50 | $graph->title->SetMargin(3); |
---|
| 51 | $graph->title->SetFont(FF_ARIAL,FS_NORMAL,12); |
---|
| 52 | |
---|
| 53 | // Create the three var series we will combine |
---|
| 54 | $bplot1 = new BarPlot($datay1); |
---|
| 55 | $bplot2 = new BarPlot($datay2); |
---|
| 56 | $bplot3 = new BarPlot($datay3); |
---|
| 57 | |
---|
| 58 | // Setup the colors with 40% transparency (alpha channel) |
---|
| 59 | $bplot1->SetFillColor('yellow@0.4'); |
---|
| 60 | $bplot2->SetFillColor('red@0.4'); |
---|
| 61 | $bplot3->SetFillColor('darkgreen@0.4'); |
---|
| 62 | |
---|
| 63 | // Setup legends |
---|
| 64 | $bplot1->SetLegend('Label 1'); |
---|
| 65 | $bplot2->SetLegend('Label 2'); |
---|
| 66 | $bplot3->SetLegend('Label 3'); |
---|
| 67 | |
---|
| 68 | // Setup each bar with a shadow of 50% transparency |
---|
| 69 | $bplot1->SetShadow('black@0.4'); |
---|
| 70 | $bplot2->SetShadow('black@0.4'); |
---|
| 71 | $bplot3->SetShadow('black@0.4'); |
---|
| 72 | |
---|
| 73 | $gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3)); |
---|
| 74 | $gbarplot->SetWidth(0.6); |
---|
| 75 | $graph->Add($gbarplot); |
---|
| 76 | |
---|
| 77 | $graph->Stroke(); |
---|
| 78 | ?> |
---|
| 79 | |
---|