47 lines
1.8 KiB
PHP
Executable File
47 lines
1.8 KiB
PHP
Executable File
<?php
|
|
// Header("Content-type: image/gif");
|
|
Header("Content-type: image/jpeg"); //if your php support JPEG
|
|
$img_width=350;
|
|
$img_height=200;
|
|
$title_font=5;
|
|
$im = imagecreate($img_width,$img_height);
|
|
|
|
$fond_img = imageColorAllocate($im, 204, 204, 204);
|
|
$noir=imageColorAllocate($im, 0, 0, 0);
|
|
$fond=imageColorAllocate($im,255,255,204);
|
|
$couleur_barre=imageColorAllocate($im,204,204,255);
|
|
|
|
ImageString($im,$title_font,($img_width-ImageFontWidth($title_font)*strlen($title))/2,0,$title,$noir);
|
|
#Draw rectangle which contain bars
|
|
imagefilledrectangle($im,25,20,$img_width-10,$img_height-10,$fond);
|
|
|
|
# Manage data
|
|
$valeurs = explode(";",$sval);
|
|
$img_width_barre=(int)(($img_width-22)/(1.5*sizeof($valeurs)+0.5));
|
|
# $max = max($valeurs);
|
|
|
|
# Max function does not work correctly in php < 4
|
|
for ($i=0;$i<sizeof($valeurs);$i++) {
|
|
if ($valeurs[$i]>$max) { $max = $valeurs[$i]; }
|
|
}
|
|
|
|
|
|
#Draw bars
|
|
for ($i=0;$i<sizeof($valeurs);$i++) {
|
|
$x=25+(int)($img_width_barre*(0.5+$i*1.5));
|
|
$img_height_barre=(int)(($valeurs[$i]*($img_height-40))/$max);
|
|
imagefilledrectangle($im,$x,$img_height-15-$img_height_barre,$x+$img_width_barre,$img_height-15,$couleur_barre);
|
|
if ($valeurs[$i] == $max) {
|
|
ImageString($im,2,4,($img_height-15-$img_height_barre)-(ImageFontHeight(2)/2),$valeurs[$i],$noir);
|
|
imageline($im,20,$img_height-15-$img_height_barre,$img_width-2,$img_height-15-$img_height_barre,$fond_img);
|
|
}
|
|
# write x axis every 2 hours
|
|
if (($i % 2)==0) ImageString($im,1,$x,$img_height-9,$i,$noir);
|
|
}
|
|
|
|
ImageString($im,2,0,0,"hits",$noir);
|
|
ImageString($im,1,($img_width-ImageFontWidth(1)*strlen("H")),$img_height-9,"heures",$noir);
|
|
// ImageGIF($im);
|
|
ImageJPEG($im);
|
|
ImageDestroy($im);
|
|
?>
|