1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
-------------------------Code de base-----------------------
<?php
require_once "../Pie.class.php";
//début du graphe
$graph = new Graph(400, 250);
$graph->setBackgroundGradient(
new LinearGradient(
new White,
new VeryLightGray,
0
)
);
$graph->title->set("Pie (example 4)");
$graph->shadow->setSize(7);
$graph->shadow->smooth(TRUE);
$graph->shadow->setPosition(SHADOW_LEFT_BOTTOM);
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>
------------------Code modifié-------------------------------
<?php
include("connect.php");
require_once "../Pie.class.php";
//fonction qui permet de calculer un pourcentage
function pourcentage($nombre,$total,$pourcent)
{
$nbr = ($nombre/$total) * $pourcent;
return round($nbr);
}
//reqûete qui va extraire tous les jurys par série
$req = "SELECT numjury FROM `copie` where numserie = '1' ORDER BY `numjury`";
$result_jury = mysql_query($req);
$nb_jury = mysql_num_rows($result_jury);
//fourchette de notes
$inf8=0;
$nb812=0;
$nb1316=0;
$sup16=0;
while ($row_jury = mysql_fetch_array($result_jury))
//debut requete jury
{
$num_jury = $row_jury["numjury"];
$requete = "select copieA, copieB, copieC, copieD, copieE, copieF, copieG, copieH, copieI, copieJ, copieK, copieL, copieM, copieN,copieO from copie where numjury='".$num_jury."' and numserie='1'";
$result = mysql_query($requete);
while ($row = mysql_fetch_array($result))
{
$copieA = $row['copieA'];
$copieB = $row['copieB'];
$copieC = $row['copieC'];
$copieD = $row['copieD'];
$copieE = $row['copieE'];
$copieF = $row['copieF'];
$copieG = $row['copieG'];
$copieH = $row['copieH'];
$copieI = $row['copieI'];
$copieJ = $row['copieJ'];
$copieK = $row['copieK'];
$copieL = $row['copieL'];
$copieM = $row['copieM'];
$copieN = $row['copieN'];
$copieO = $row['copieO'];
$tab_val = array($copieA, $copieB, $copieC, $copieD, $copieE, $copieF, $copieG, $copieH, $copieI, $copieJ, $copieK, $copieL, $copieM, $copieN, $copieO);
for($i=0;$i<sizeof($tab_val);$i++){ // tant que $i est inferieur au nombre d'éléments du tableau...
$tab_val[$i];
if($tab_val[$i] < '8'){
$inf8++;
}
else {
if(($tab_val[$i] >= '8') && ($tab_val[$i] <= '12')){
$nb812++;
}
else {
if(($tab_val[$i] >= '13') && ($tab_val[$i] <= '16')){
$nb1316++;
}
else {
if($tab_val[$i] > '16'){
$sup16++;
}
}
}
}
}
//echo "<br>";
}
}
$nb_total = sizeof($tab_val);
$nbjur = $nb_total * $nb_jury;
//echo $resultat = ($inf8/$nbjur) * $pourcentage;
$purcent1 = pourcentage($inf8,$nbjur,100)." %";
$purcent2 = pourcentage($nb812,$nbjur,100)." %";
$purcent3 = pourcentage($nb1316,$nbjur,100)." %";
$purcent4 = pourcentage($sup16,$nbjur,100)." %";
//début du graphe
$graph = new Graph(400, 250);
$graph->setBackgroundGradient(
new LinearGradient(
new White,
new VeryLightGray,
0
)
);
$graph->title->set("Pie (example 4)");
$graph->shadow->setSize(4);
$graph->shadow->smooth(TRUE);
$graph->shadow->setPosition(SHADOW_LEFT_BOTTOM);
$values = array($purcent1 , $purcent2, $purcent3, $purcent4);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setLegend(array(
'Note1',
'Note2',
'Note3',
'Note4'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?> |