1 | <?php |
---|
2 | $DataSet = new xsPData(); |
---|
3 | $DataSet->AddPoint($labels, "Serie1"); |
---|
4 | $DataSet->AddPoint($presences, "Serie2"); |
---|
5 | $DataSet->AddPoint($participations, "Serie3"); |
---|
6 | $DataSet->AddPoint($mots, "Serie4"); |
---|
7 | $DataSet->AddSerie("Serie2"); |
---|
8 | $DataSet->AddSerie("Serie3"); |
---|
9 | $DataSet->AddSerie("Serie4"); |
---|
10 | $DataSet->SetAbsciseLabelSerie("Serie1"); |
---|
11 | $DataSet->SetYAxisName("Séances par semaine"); |
---|
12 | |
---|
13 | $DataSetBordure = new xsPData(); |
---|
14 | $DataSetBordure->AddPoint($labels, "Serie1"); |
---|
15 | $DataSetBordure->AddPoint($presences, "Serie2"); |
---|
16 | $DataSetBordure->AddPoint(array_fill(1, count($labels), 0), "Serie5"); |
---|
17 | $DataSetBordure->AddSerie("Serie2"); |
---|
18 | $DataSetBordure->AddSerie("Serie5"); |
---|
19 | $DataSetBordure->SetAbsciseLabelSerie("Serie1"); |
---|
20 | |
---|
21 | $DataSet2 = new xsPData(); |
---|
22 | $DataSet2->AddPoint($labels, "Serie1"); |
---|
23 | $DataSet2->AddPoint($vacances, "Serie6"); |
---|
24 | $DataSet2->AddSerie("Serie6"); |
---|
25 | $DataSet2->SetAbsciseLabelSerie("Serie1"); |
---|
26 | |
---|
27 | if (isset($n_questions) && $type != 'commission') { |
---|
28 | $questions = 1; |
---|
29 | $DataSet3 = new xsPData(); |
---|
30 | $DataSet3->AddPoint($labels, "Serie1"); |
---|
31 | $DataSet3->AddPoint($n_questions, "Serie7"); |
---|
32 | $DataSet3->AddSerie("Serie7"); |
---|
33 | $DataSet3->SetAbsciseLabelSerie("Serie1"); |
---|
34 | $Data3 = $DataSet3->GetData(); |
---|
35 | $DataDescr3 = $DataSet3->GetDataDescription(); |
---|
36 | } else $questions = 0; |
---|
37 | |
---|
38 | $Data = $DataSet->GetData(); |
---|
39 | $DataDescr = $DataSet->GetDataDescription(); |
---|
40 | $DataBordure = $DataSetBordure->GetData(); |
---|
41 | $DataDescrBordure = $DataSetBordure->GetDataDescription(); |
---|
42 | $Data2 = $DataSet2->GetData(); |
---|
43 | $DataDescr2 = $DataSet2->GetDataDescription(); |
---|
44 | |
---|
45 | if (isset($link)) { |
---|
46 | $font = 9; |
---|
47 | $ticks = 2; |
---|
48 | $scale = 14; |
---|
49 | $size = 150; |
---|
50 | } else { |
---|
51 | $font = 12; |
---|
52 | $ticks = 1; |
---|
53 | if ($type =='total') { |
---|
54 | $scale = 14; |
---|
55 | $size = 300; |
---|
56 | } else if ($type == 'commission') { |
---|
57 | $scale = 7; |
---|
58 | $size = 185; // 70+$scale/$scaletotal*($sizetotal-70) |
---|
59 | } else if ($type == 'hemicycle') { |
---|
60 | $scale = 12; |
---|
61 | $size = 267; |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | $Test = new xsPChart(800,$size); |
---|
66 | $Test->setGraphArea(25+3*$font,3*$font,780,$size-10-2*$font); |
---|
67 | $Test->drawFilledRoundedRectangle(7,7,793,$size-7,5,240,240,240); |
---|
68 | $Test->drawRoundedRectangle(5,5,795,$size - 5,5,230,230,230); |
---|
69 | $Test->drawGraphArea(230,230,230,FALSE); |
---|
70 | $Test->setFixedScale(0,$scale,$scale/$ticks); |
---|
71 | $Test->xsSetFontProperties("tahoma.ttf",$font); |
---|
72 | $Test->drawScale($Data,$DataDescr,SCALE_NORMAL,50,50,50,TRUE,0,0,FALSE,1,TRUE); |
---|
73 | $Test->drawGrid(0,TRUE,0,0,0,100); |
---|
74 | $Test->setColorPalette(0,50,50,50); |
---|
75 | $Test->drawOverlayBarGraph($Data2,$DataDescr2,30,100); |
---|
76 | $fonction = 0; |
---|
77 | if (isset($fonctions)) { |
---|
78 | $total = array_sum($presences); |
---|
79 | if ($total != 0) { |
---|
80 | if ($type == 'total') { |
---|
81 | $totalfonctions = $fonctions['hemicycle']+$fonctions['commission']; |
---|
82 | } else { |
---|
83 | $totalfonctions = $fonctions[$type]; |
---|
84 | } |
---|
85 | $fonction = (int)(4*$totalfonctions/$total); |
---|
86 | } |
---|
87 | } |
---|
88 | $Test->setColorPalette(0,255,35*$fonction,0); |
---|
89 | $Test->setColorPalette(1,255,255,0); |
---|
90 | $Test->setColorPalette(2,0,255,0); |
---|
91 | $Test->drawFilledLineGraph($Data,$DataDescr,78); |
---|
92 | if ($questions == 1) { |
---|
93 | $Test->setColorPalette(0,0,0,255); |
---|
94 | $Test->drawOverlayBarGraph($Data3,$DataDescr3,85,25); |
---|
95 | } |
---|
96 | $Test->setColorPalette(0,255,35*$fonction,0); |
---|
97 | $Test->setColorPalette(1,0,0,0); |
---|
98 | $Test->drawLineGraph($DataBordure,$DataDescrBordure); |
---|
99 | $Test->xsSetFontProperties("tahoma.ttf",$font + 3); |
---|
100 | $pos_titre = 240; |
---|
101 | if ($time == 'lastyear') { |
---|
102 | if (isset($mandat_clos)) { |
---|
103 | $pos_titre = 210; |
---|
104 | $duree = ' sa dernière année de mandat'; |
---|
105 | } else $duree = 's 12 derniers mois'; |
---|
106 | $shortduree = 'annee'; |
---|
107 | } else { |
---|
108 | $duree = " la session ".preg_replace('/^(\d{4})/', '\\1-', $time); |
---|
109 | $shortduree = $time; |
---|
110 | } |
---|
111 | if ($type == 'total') { |
---|
112 | $Test->drawTitle($pos_titre,3 + 2*$font,"Participation globale au cours de".$duree." (hémicycle et commissions)",50,50,50,585); |
---|
113 | $titre = 'globale-'.$shortduree; |
---|
114 | } else { |
---|
115 | $titre = $type; |
---|
116 | if ($type == 'commission') $titre .= 's'; |
---|
117 | $Test->drawTitle($pos_titre+30,3 + 2*$font,"Participation en ".$titre." au cours de".$duree,50,50,50,585); |
---|
118 | $titre .= '-'.$shortduree; |
---|
119 | } |
---|
120 | $filename = 'participation-'.$titre.'-'.$parlementaire->slug.isset($link).'.png'; |
---|
121 | $Test->xsRender($filename); |
---|
122 | |
---|
123 | if (isset($link)) |
---|
124 | echo link_to(image_tag('tmp/xspchart/'.$filename, 'alt="Participation '.$titre.' de '.$parlementaire->nom.'"'), '@parlementaire_plot?slug='.$parlementaire->slug.'&time=lastyear'); |
---|
125 | else echo '<div class="par_session">'.image_tag('tmp/xspchart/'.$filename, 'alt="Participation '.$titre.' de '.$parlementaire->nom.'"'); |
---|
126 | echo "<p><span style='background-color: rgb(255,"; |
---|
127 | echo 35*$fonction.",0);'> </span> "; |
---|
128 | if ($type == 'commission') echo ' Présences enregistrées '; else echo ' Présences relevées '; |
---|
129 | echo "<span style='background-color: rgb(255,200,0);'> </span> Participations "; |
---|
130 | echo "<span style='background-color: rgb(0,255,0);'> </span> Mots prononcés (x 10 000) "; |
---|
131 | if ($questions == 1) |
---|
132 | echo "<span style='background-color: rgb(0,0,255);'> </span> Questions orales "; |
---|
133 | echo "<span style='background-color: rgb(150,150,150);'> </span> Vacances parlementaires"; |
---|
134 | if (isset($link)) |
---|
135 | echo " ".link_to('Explications', '@parlementaire_plot?slug='.$parlementaire->slug.'&time=lastyear#explications').'</p>'; |
---|
136 | else echo '</p></div>' |
---|
137 | ?> |
---|