source: trunk/client/modules/Elezioni/grafici-old/barre.php@ 11

Last change on this file since 11 was 2, checked in by root, 15 years ago

importo il progetto

File size: 3.6 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8
9include ("jpgraph.php");
10include ("jpgraph_bar.php");
11
12
13$dati1=$_GET['dati1'];$dati2=$_GET['dati2'];$i=$_GET['i'];$l=$_GET['l'];$w=$_GET['w'];
14$titolo=$_GET['titolo'];$descr=$_GET['descr'];$cop=$_GET['cop'];
15$logo=$_GET['logo'];
16$datay=unserialize(stripslashes($dati1)); // percentuali
17$datax=unserialize(stripslashes($dati2)); // candidati
18
19
20// $i= numero candidati
21// $larghezza label
22if (!isset($l)) $l=180;
23if (!isset($w)) $w=500;
24if ($l=='') $l=180;
25if ($w=='') $w=500;
26
27//$datay=array(2,3,5,8,12,6,3);
28//$datax=array("Jan","Feb","Mar","Apr","May","Jun","Jul");
29
30//$datay=$pro;
31//$datax=$pro;
32// Size of graph
33$width=$w;
34$height=$i*30;
35
36// Set the basic parameters of the graph
37$graph = new Graph($width,$height,'auto');
38$graph->SetScale("textlin");
39
40$top = 50;
41$bottom = 80;
42$left = $l;
43$right = 40;
44$graph->Set90AndMargin($left,$right,$top,$bottom);
45#if(isset($logo)) $graph->SetBackgroundImage("../images/".$logo.".png",BGIMG_COPY);
46#else
47$graph->SetBackgroundImage("../images/vuoto.jpg",BGIMG_COPY);
48// Nice shadow
49$graph->SetShadow();
50
51// Setup title
52$graph->title->Set("$titolo");
53$graph->title->SetFont(FF_FONT1,FS_BOLD,10);
54$graph->subtitle->Set("$descr");
55
56// Setup X-axis
57$graph->xaxis->SetTickLabels($datax);
58$graph->xaxis->SetFont(FF_FONT1,FS_BOLD,8);
59$graph->xaxis->SetColor("black","darkred");
60// Some extra margin looks nicer
61$graph->xaxis->SetLabelMargin(5);
62
63// Label align for X-axis
64$graph->xaxis->SetLabelAlign('right','center');
65
66// Add some grace to y-axis so the bars doesn't go
67// all the way to the end of the plot area
68$graph->yaxis->scale->SetGrace(20);
69
70// Setup the Y-axis to be displayed in the bottom of the
71// graph. We also finetune the exact layout of the title,
72// ticks and labels to make them look nice.
73$graph->yaxis->SetPos('max');
74
75// First make the labels look right
76$graph->yaxis->SetLabelAlign('center','top');
77$graph->yaxis->SetLabelFormat('%d');
78$graph->yaxis->SetLabelSide(SIDE_RIGHT);
79
80// The fix the tick marks
81$graph->yaxis->SetTickSide(SIDE_LEFT);
82
83// Finally setup the title
84$graph->yaxis->SetTitleSide(SIDE_RIGHT);
85$graph->yaxis->SetTitleMargin(35);
86
87// To align the title to the right use :
88$graph->yaxis->SetTitle("$cop",'high');
89$graph->yaxis->title->Align('right');
90$graph->yaxis->SetColor("black","darkred");
91// To center the title use :
92//$graph->yaxis->SetTitle('Turnaround 2002','center');
93//$graph->yaxis->title->Align('center');
94
95$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD,12);
96$graph->yaxis->title->SetAngle(0);
97
98
99
100$graph->yaxis->SetFont(FF_FONT2,FS_NORMAL);
101// If you want the labels at an angle other than 0 or 90
102// you need to use TTF fonts
103//$graph->yaxis->SetLabelAngle(0);
104
105/*
106// testo
107$txt =new Text("$cop");
108$txt->Pos( 100,$i*29);
109$txt->SetColor( "red");
110$graph->AddText( $txt);
111*/
112
113
114
115
116
117
118
119
120// Now create a bar pot
121$bplot = new BarPlot($datay);
122$bplot->SetFillColor("orange");
123$bplot->SetShadow();
124
125//You can change the width of the bars if you like
126$bplot->SetWidth(0.1);
127
128// We want to display the value of each bar at the top
129$bplot->value->Show();
130$bplot->value->SetFont(FF_FONT1,FS_BOLD,12);
131$bplot->value->SetAlign('left','center');
132$bplot->value->SetColor("black","darkred");
133$bplot->value->SetFormat('%.2f perc');
134
135// Add the bar to the graph
136$graph->Add($bplot);
137
138
139$graph->Stroke();
140?>
Note: See TracBrowser for help on using the repository browser.