1 | <?php |
---|
2 | |
---|
3 | $data = unserialize(get_component('plot', 'getParlData', array('parlementaire' => $parlementaire, 'session' => $time))); |
---|
4 | |
---|
5 | $n = count($data['labels']); |
---|
6 | $presences = array_fill(1, $n, 0); |
---|
7 | $participations = array_fill(1, $n, 0); |
---|
8 | $mots = array_fill(1, $n, 0); |
---|
9 | if ($type === 'total') for ($i = 1; $i <= $n; $i++) { |
---|
10 | $presences[$i] = $data['n_presences']['hemicycle'][$i] + $data['n_presences']['commission'][$i]; |
---|
11 | $participations[$i] = $data['n_participations']['hemicycle'][$i] + $data['n_participations']['commission'][$i]; |
---|
12 | $mots[$i] = $data['n_mots']['hemicycle'][$i] + $data['n_mots']['commission'][$i]; |
---|
13 | } else if ($type === 'hemicycle' || $type === 'commission') { |
---|
14 | $presences = $data['n_presences']["$type"]; |
---|
15 | $participations = $data['n_participations']["$type"]; |
---|
16 | $mots = $data['n_mots']["$type"]; |
---|
17 | } |
---|
18 | |
---|
19 | if ($link === 'true') { |
---|
20 | $font = 9; |
---|
21 | $ticks = 2; |
---|
22 | $scale = 14; |
---|
23 | $size = 150; |
---|
24 | } else { |
---|
25 | $font = 12; |
---|
26 | $ticks = 1; |
---|
27 | if ($type === 'total') { |
---|
28 | $scale = 14; |
---|
29 | $size = 300; |
---|
30 | } else if ($type === 'commission') { |
---|
31 | $scale = 7; |
---|
32 | $size = 185; // 70+$scale/$scaletotal*($sizetotal-70) |
---|
33 | } else if ($type === 'hemicycle') { |
---|
34 | $scale = 12; |
---|
35 | $size = 267; |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | if ($drawAction === "map" ) { |
---|
40 | $Test = new xsPChart(800,$size); |
---|
41 | $Test->getImageMap($mapId); |
---|
42 | } |
---|
43 | |
---|
44 | $DataSet = new xsPData(); |
---|
45 | $DataSet->AddPoint($data['labels'], "Serie1"); |
---|
46 | $DataSet->AddPoint($presences, "Serie2"); |
---|
47 | $DataSet->AddPoint($participations, "Serie3"); |
---|
48 | $DataSet->AddPoint($mots, "Serie4"); |
---|
49 | $DataSet->AddSerie("Serie2"); |
---|
50 | $DataSet->AddSerie("Serie3"); |
---|
51 | $DataSet->AddSerie("Serie4"); |
---|
52 | $DataSet->SetAbsciseLabelSerie("Serie1"); |
---|
53 | $DataSet->SetYAxisName("Séances par semaine"); |
---|
54 | |
---|
55 | $DataSetLegend = new xsPData(); |
---|
56 | $DataSetLegend->AddPoint($data['labels'], "Serie1"); |
---|
57 | $DataSetLegend->AddPoint($presences, "Serie2"); |
---|
58 | $DataSetLegend->AddPoint($participations, "Serie3"); |
---|
59 | $DataSetLegend->AddSerie("Serie2"); |
---|
60 | $DataSetLegend->AddSerie("Serie3"); |
---|
61 | $DataSetLegend->SetSerieName(utf8_decode('Présences'),"Serie2"); |
---|
62 | $DataSetLegend->SetSerieName("Participations","Serie3"); |
---|
63 | $DataSetLegend->SetAbsciseLabelSerie("Serie1"); |
---|
64 | |
---|
65 | $DataSetBordure = new xsPData(); |
---|
66 | $DataSetBordure->AddPoint($data['labels'], "Serie1"); |
---|
67 | $DataSetBordure->AddPoint($presences, "Serie2"); |
---|
68 | $DataSetBordure->AddPoint(array_fill(1, count($data['labels']), 0), "Serie5"); |
---|
69 | $DataSetBordure->AddSerie("Serie2"); |
---|
70 | $DataSetBordure->AddSerie("Serie5"); |
---|
71 | $DataSetBordure->SetAbsciseLabelSerie("Serie1"); |
---|
72 | |
---|
73 | $DataSet2 = new xsPData(); |
---|
74 | $DataSet2->AddPoint($data['labels'], "Serie1"); |
---|
75 | $DataSet2->AddPoint($data['vacances'], "Serie6"); |
---|
76 | $DataSet2->AddSerie("Serie6"); |
---|
77 | $DataSet2->SetAbsciseLabelSerie("Serie1"); |
---|
78 | |
---|
79 | if ($questions === 'true' && $type != 'commission') { |
---|
80 | $DataSet3 = new xsPData(); |
---|
81 | $DataSet3->AddPoint($data['labels'], "Serie1"); |
---|
82 | $DataSet3->AddPoint($data['n_questions'], "Serie7"); |
---|
83 | $DataSet3->AddSerie("Serie7"); |
---|
84 | $DataSet3->SetAbsciseLabelSerie("Serie1"); |
---|
85 | $Data3 = $DataSet3->GetData(); |
---|
86 | $DataDescr3 = $DataSet3->GetDataDescription(); |
---|
87 | } |
---|
88 | |
---|
89 | $Data = $DataSet->GetData(); |
---|
90 | $DataDescr = $DataSet->GetDataDescription(); |
---|
91 | $DataBordure = $DataSetBordure->GetData(); |
---|
92 | $DataDescrBordure = $DataSetBordure->GetDataDescription(); |
---|
93 | $Data2 = $DataSet2->GetData(); |
---|
94 | $DataDescr2 = $DataSet2->GetDataDescription(); |
---|
95 | $DataLegend = $DataSetLegend->GetData(); |
---|
96 | $DataDescrLegend = $DataSetLegend->GetDataDescription(); |
---|
97 | |
---|
98 | $Test = new xsPChart(800,$size); |
---|
99 | $Test->setGraphArea(25+3*$font,3*$font,780,$size-10-2*$font); |
---|
100 | $Test->drawFilledRoundedRectangle(7,7,793,$size-7,5,240,240,240); |
---|
101 | $Test->drawRoundedRectangle(5,5,795,$size - 5,5,230,230,230); |
---|
102 | $Test->drawGraphArea(230,230,230,FALSE); |
---|
103 | $Test->setFixedScale(0,$scale,$scale/$ticks); |
---|
104 | $Test->xsSetFontProperties("tahoma.ttf",$font); |
---|
105 | $Test->drawScale($Data,$DataDescr,SCALE_NORMAL,50,50,50,TRUE,0,0,FALSE,1,FALSE); |
---|
106 | if ($link === 'true') { |
---|
107 | $Test->setColorPalette(0,255,255,255); |
---|
108 | $Test->setColorPalette(1,255,255,255); |
---|
109 | $Test->setImageMap(TRUE,$mapId); |
---|
110 | $Test->drawOverlayBarGraph($DataLegend,$DataDescrLegend,30,100); |
---|
111 | $Test->setImageMap(FALSE,$mapId); |
---|
112 | } |
---|
113 | $Test->drawGrid(0,TRUE,0,0,0,100); |
---|
114 | $Test->setColorPalette(0,50,50,50); |
---|
115 | $Test->drawOverlayBarGraph($Data2,$DataDescr2,30,100); |
---|
116 | $Test->setColorPalette(0,255,0,0); |
---|
117 | $Test->setColorPalette(1,255,255,0); |
---|
118 | $Test->setColorPalette(2,0,255,0); |
---|
119 | $Test->drawFilledLineGraph($Data,$DataDescr,78); |
---|
120 | if ($questions === 'true' && $type != 'commission') { |
---|
121 | $Test->setColorPalette(0,0,0,255); |
---|
122 | $Test->drawOverlayBarGraph($Data3,$DataDescr3,85,25); |
---|
123 | } |
---|
124 | $Test->setColorPalette(0,255,0,0); |
---|
125 | $Test->setColorPalette(1,0,0,0); |
---|
126 | $Test->drawLineGraph($DataBordure,$DataDescrBordure); |
---|
127 | |
---|
128 | $Test->xsSetFontProperties("tahoma.ttf",$font + 3); |
---|
129 | $pos_titre = 240; |
---|
130 | if ($time === 'lastyear') { |
---|
131 | if (isset($data['mandat_clos'])) { |
---|
132 | $pos_titre = 210; |
---|
133 | $duree = ' sa dernière année de mandat'; |
---|
134 | } else $duree = 's 12 derniers mois'; |
---|
135 | $shortduree = 'annee'; |
---|
136 | } else { |
---|
137 | $duree = " la session ".preg_replace('/^(\d{4})/', '\\1-', $time); |
---|
138 | $shortduree = $time; |
---|
139 | } |
---|
140 | if ($type === 'total') { |
---|
141 | $Test->drawTitle($pos_titre,3 + 2*$font,"Participation globale au cours de".$duree." (hémicycle et commissions)",50,50,50,585); |
---|
142 | $titre = 'globale-'.$shortduree; |
---|
143 | } else { |
---|
144 | $titre = $type; |
---|
145 | if ($type === 'commission') $titre .= 's'; |
---|
146 | $Test->drawTitle($pos_titre+30,3 + 2*$font,"Participation en ".$titre." au cours de".$duree,50,50,50,585); |
---|
147 | $titre .= '-'.$shortduree; |
---|
148 | } |
---|
149 | if ($link === 'true') |
---|
150 | $Test->setImageMap(TRUE,$mapId); |
---|
151 | |
---|
152 | $Test->xsStroke(); |
---|
153 | |
---|
154 | ?> |
---|