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
| <?php
$GraphiqueWidth=600;
$GraphiqueHeight=400;
$GraphiqueUnite=20;
$GraphiquePolice=3;
$GraphiqueDonnee=array($res1,$res2,$res3,$res4);
$GraphiqueDonnee1=array($res5,$res6,$res7,$res8);
$GraphiqueDonnee2=array($res9,$res10,$res11,$res12);
/* Création de l'image */
$image=imagecreate($GraphiqueWidth, $GraphiqueHeight);
/* Définition des couleurs */
$CouleurCorps=imagecolorallocate($image, 0xcc, 0xcc, 0xcc);
$CouleurTexte=imagecolorallocate($image, 0x00, 0x33, 0x33);
$CouleurRectangle=imagecolorallocate($image, 0xFF, 0x33, 0x33);
$CouleurRectangle1=imagecolorallocate($image, 0xFF, 0x66, 0x66);
$CouleurRectangle2=imagecolorallocate($image, 0xFF, 0x99, 0x99);
$CouleurRectangle3=imagecolorallocate($image, 0xFF, 0xCC, 0xCC);
$CouleurHache=imagecolorallocate($image, 0x00, 0x00, 0x00);
/* Définition de l'arrière-plan */
imagefill($image, 0, 0, $CouleurCorps);
/* Création des lignes verticales */
$TexteHacheWidth=imagefontwidth($GraphiquePolice) * 3 + 1;
imageline($image, $TexteHacheWidth, 0, $TexteHacheWidth, $GraphiqueHeight - 1, $CouleurHache);
/* Création des lignes horizontales */
for($i=0;$i<$GraphiqueHeight;$i += $GraphiqueHeight / 10){
imagedashedline($image, 0, $i, $GraphiqueWidth -1, $i, $CouleurHache);
/* Affichage du nom */
imagestring($image, $GraphiquePolice, 0, $i, round(($GraphiqueHeight - $i)/$GraphiqueUnite), $CouleurTexte);
}
/* Création des lignes du bas du graphique */
imageline($image, 0, $GraphiqueHeight -1, $GraphiqueWidth -1, $GraphiqueHeight -1, $CouleurHache);
/* Création des barres */
$BarreWidth0=(($GraphiqueWidth/4 - $TexteHacheWidth) / count($GraphiqueDonnee)) - 10;
$BarreWidth1=(($GraphiqueWidth/4 - $TexteHacheWidth) / count($GraphiqueDonnee1)) - 10;
$BarreWidth2=(($GraphiqueWidth/4 - $TexteHacheWidth) / count($GraphiqueDonnee2)) - 10;
for($i=0;$i<count($GraphiqueDonnee);$i++){
$BarreWidth = ($BarreWidth0 + $BarreWidth1 + $BarreWidth2);
$BarreHautX= $TexteHacheWidth + (($i+1) *10) + ($i * $BarreWidth);
$BarreBottomX= $BarreHautX + $BarreWidth;
$BarreBottomY= $GraphiqueHeight -1;
$BarreHautY= $BarreBottomY - ($GraphiqueDonnee[$i] * $GraphiqueUnite);
$BarreHautY1= $BarreBottomY - ($GraphiqueDonnee1[$i] * $GraphiqueUnite);
$BarreHautY2= $BarreBottomY - ($GraphiqueDonnee2[$i] * $GraphiqueUnite);
imagefilledrectangle($image, $BarreHautX, $BarreHautY, $BarreBottomX-50, $BarreBottomY, $CouleurRectangle);
imagefilledrectangle($image, $BarreHautX+17, $BarreHautY1, $BarreBottomX-33, $BarreBottomY, $CouleurRectangle1);
imagefilledrectangle($image, $BarreHautX+34, $BarreHautY2, $BarreBottomX-16, $BarreBottomY, $CouleurRectangle2);
$TexteX=$BarreHautX+ (($BarreBottomX - $BarreHautX)/2) - ( imagefontheight($GraphiquePolice) / 2);
$TexteY=$BarreBottomY - $GraphiqueDonnee[$i]*$GraphiqueUnite;
$TexteY1=$BarreBottomY - $GraphiqueDonnee1[$i]*$GraphiqueUnite;
$TexteY2=$BarreBottomY - $GraphiqueDonnee2[$i]*$GraphiqueUnite;
//affichage des infos barres
if ($GraphiqueDonnee[$i]==0)
{
imagestring($image, $GraphiquePolice, $TexteX-24, $TexteY-40, "$GraphiqueDonnee[$i]", $CouleurTexte);
}
else
{
imagestring($image, $GraphiquePolice, $TexteX-24, $TexteY-15, "$GraphiqueDonnee[$i]", $CouleurTexte);
}
if ($GraphiqueDonnee1[$i]==0)
{
imagestring($image, $GraphiquePolice, $TexteX-7, $TexteY1-40, "$GraphiqueDonnee1[$i]", $CouleurTexte);
}
else
{
imagestring($image, $GraphiquePolice, $TexteX-7, $TexteY1-15, "$GraphiqueDonnee1[$i]", $CouleurTexte);
}
if ($GraphiqueDonnee2[$i]==0)
{
imagestring($image, $GraphiquePolice, $TexteX+10, $TexteY2-40, "$GraphiqueDonnee2[$i]", $CouleurTexte);
}
else
{
imagestring($image, $GraphiquePolice, $TexteX+10, $TexteY2-15, "$GraphiqueDonnee2[$i]", $CouleurTexte);
}
//affichage des circonstances
imagestring($image, $GraphiquePolice, 45, 385, "$GraphiqueTexte[0]", $CouleurTexte);
imagestring($image, $GraphiquePolice, 105, 385, "$GraphiqueTexte[1]", $CouleurTexte);
imagestring($image, $GraphiquePolice, 185, 385, "$GraphiqueTexte[2]", $CouleurTexte);
imagestring($image, $GraphiquePolice, 270, 385, "$GraphiqueTexte[3]", $CouleurTexte);
//legende
$Resultat=$GraphiqueDonnee[0]+$GraphiqueDonnee[1]+$GraphiqueDonnee[2]+$GraphiqueDonnee[3];
$Resultat1=$GraphiqueDonnee1[0]+$GraphiqueDonnee1[1]+$GraphiqueDonnee1[2]+$GraphiqueDonnee1[3];
$Resultat2=$GraphiqueDonnee2[0]+$GraphiqueDonnee2[1]+$GraphiqueDonnee2[2]+$GraphiqueDonnee2[3];
imagefilledrectangle($image, 400, 25, 415, 10, $CouleurRectangle);
imagestring($image, $GraphiquePolice, 420, 10, "".$Resultat, $CouleurTexte);
imagefilledrectangle($image, 400, 40, 415, 25, $CouleurRectangle1);
imagestring($image, $GraphiquePolice, 420, 25, " ".$Resultat1, $CouleurTexte);
imagefilledrectangle($image, 400, 55, 415, 40, $CouleurRectangle2);
imagestring($image, $GraphiquePolice, 420, 40, "".$Resultat2, $CouleurTexte);
imagestring($image, $GraphiquePolice, 145, 80, "TITRE", $CouleurTexte);
}
header("Content-type: image/gif");
imagegif($image);
?> |
Partager