Un jolie histogrammes pour les statistique (parametrable
?id1=nb1&id2=nb2&id3=nb3&id4=nb4&id5=nb5&pid1=nom1&pid2=nom2&pid3=nom3&pid4=nom4&pid5=nom5)
Source / Exemple :
<?
if(isset($_GET['id1']) && isset($_GET['id2']) && isset($_GET['id3']) && isset($_GET['id4']) && isset($_GET['id5']) && isset($_GET['pid1']) && isset($_GET['pid2']) && isset($_GET['pid3']) && isset($_GET['pid4']) && isset($_GET['pid5']))
{
/*
- Histogramme au format GIF
- /
//Les paramètres
$GraphWidth = 400;
$GraphHeight = 200;
$GraphScale = 2;
$GraphFont = 5;
$GraphData = array($_GET['id1'], $_GET['id2'],
$_GET['id3'], $_GET['id4'], $_GET['id5']);
$GraphLabel = array($_GET['pid1'], $_GET['pid2'],
$_GET['pid3'], $_GET['pid4'], $_GET['pid5']);
//L'image
$image = imagecreate($GraphWidth, $GraphHeight);
//allocate colors
$colorBody = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$colorGrid = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
$colorBar = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$colorText = imagecolorallocate($image, 0x00, 0x00, 0x00);
//L'arrière-plan
imagefill($image, 0, 0, $colorBody);
//Les lignes verticales
$GridLabelWidth = imagefontwidth($GraphFont)*3 + 1;
imageline($image,
$GridLabelWidth, 0,
$GridLabelWidth, $GraphHeight-1,
$colorGrid);
//Les lignes horizontales
for($index = 0; $index < $GraphHeight; $index += $GraphHeight/10)
{
imagedashedline($image,
0, $index,
$GraphWidth-1, $index,
$colorGrid);
//Le titre
imagestring($image,
$GraphFont,
0,
$index,
round(($GraphHeight - $index)/$GraphScale),
$colorText);
}
//Les lignes du bas
imageline($image,
0, $GraphHeight-1,
$GraphWidth-1, $GraphHeight-1,
$colorGrid);
//Les barres
$BarWidth = (($GraphWidth-$GridLabelWidth)/count($GraphData)) - 10;
for($index = 0; $index < count($GraphData); $index++)
{
//dessiner une barre
$BarTopX = $GridLabelWidth + (($index+1) * 10) + ($index * $BarWidth);
$BarBottomX = $BarTopX + $BarWidth;
$BarBottomY = $GraphHeight-1;
$BarTopY = $BarBottomY - ($GraphData[$index] * $GraphScale);
imagefilledrectangle($image,
$BarTopX, $BarTopY,
$BarBottomX, $BarBottomY,
$colorBar);
//tracer le titre
$LabelX = $BarTopX +
(($BarBottomX - $BarTopX)/2) -
(imagefontheight($GraphFont)/2);
$LabelY = $BarBottomY-10;
imagestringup($image,
$GraphFont,
$LabelX,
$LabelY,
"$GraphLabel[$index]: $GraphData[$index]",
$colorText);
}
//afficher l'image
header("Content-type: image/gif");
imagegif($image);
}else{
echo '<fieldset style="position:absolute;border-color:#0000FF;border:1 solid"><b>Une erreur c\'est produite lors de la création du graphique :<br><li><font color=red>Tout les Arguments ne sont pas spécifier</b></font></fieldset>';
}
?>
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.