| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
include ("../jpgraph.php");
|
|
|
4 |
include ("../jpgraph_bar.php");
|
|
|
5 |
include ("../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 |
// Apply a perspective transformation at the end
|
|
|
21 |
$graph->Set3DPerspective(SKEW3D_LEFT,350,320,true);
|
|
|
22 |
|
|
|
23 |
// Adjust the position of the legend box
|
|
|
24 |
$graph->legend->Pos(0.03,0.10);
|
|
|
25 |
|
|
|
26 |
// Adjust the color for theshadow of the legend
|
|
|
27 |
$graph->legend->SetShadow('darkgray@0.5');
|
|
|
28 |
$graph->legend->SetFillColor('lightblue@0.1');
|
|
|
29 |
$graph->legend->Hide();
|
|
|
30 |
|
|
|
31 |
// Get localised version of the month names
|
|
|
32 |
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
|
|
|
33 |
|
|
|
34 |
$graph->SetBackgroundCountryFlag('mais',BGIMG_COPY,50);
|
|
|
35 |
|
|
|
36 |
// Set axis titles and fonts
|
|
|
37 |
$graph->xaxis->title->Set('Year 2002');
|
|
|
38 |
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
|
|
39 |
$graph->xaxis->title->SetColor('white');
|
|
|
40 |
|
|
|
41 |
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
|
|
42 |
$graph->xaxis->SetColor('navy');
|
|
|
43 |
|
|
|
44 |
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
|
|
|
45 |
$graph->yaxis->SetColor('navy');
|
|
|
46 |
|
|
|
47 |
//$graph->ygrid->Show(false);
|
|
|
48 |
$graph->ygrid->SetColor('white@0.5');
|
|
|
49 |
|
|
|
50 |
// Setup graph title
|
|
|
51 |
$graph->title->Set('Using a country flag background');
|
|
|
52 |
|
|
|
53 |
// Some extra margin (from the top)
|
|
|
54 |
$graph->title->SetMargin(3);
|
|
|
55 |
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
|
|
|
56 |
|
|
|
57 |
// Create the three var series we will combine
|
|
|
58 |
$bplot1 = new BarPlot($datay1);
|
|
|
59 |
$bplot2 = new BarPlot($datay2);
|
|
|
60 |
$bplot3 = new BarPlot($datay3);
|
|
|
61 |
|
|
|
62 |
// Setup the colors with 40% transparency (alpha channel)
|
|
|
63 |
$bplot1->SetFillColor('yellow@0.4');
|
|
|
64 |
$bplot2->SetFillColor('red@0.4');
|
|
|
65 |
$bplot3->SetFillColor('darkgreen@0.4');
|
|
|
66 |
|
|
|
67 |
// Setup legends
|
|
|
68 |
$bplot1->SetLegend('Label 1');
|
|
|
69 |
$bplot2->SetLegend('Label 2');
|
|
|
70 |
$bplot3->SetLegend('Label 3');
|
|
|
71 |
|
|
|
72 |
// Setup each bar with a shadow of 50% transparency
|
|
|
73 |
$bplot1->SetShadow('black@0.4');
|
|
|
74 |
$bplot2->SetShadow('black@0.4');
|
|
|
75 |
$bplot3->SetShadow('black@0.4');
|
|
|
76 |
|
|
|
77 |
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
|
|
|
78 |
$gbarplot->SetWidth(0.6);
|
|
|
79 |
$graph->Add($gbarplot);
|
|
|
80 |
|
|
|
81 |
$graph->Stroke();
|
|
|
82 |
?>
|
|
|
83 |
|