|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
CREATION D'UN HISTOGRAMME IDEAL POUR LES STATISTIQUES [TITRE MODERE CAR BOURRE DE FAUTES...]
Information sur la source
Description
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
- <?
-
- 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>';
-
-
- }
- ?>
<?
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>';
}
?>
Historique
- 23 septembre 2005 19:54:23 :
- rajout de l'url :)
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
graphique, histogramme, diagramme... [ par jbardet ]
Bonjour,Je souhaite créer des digramme de stat en php (+ exactement avec smarty) mais deja si j'y arrive en php ça le ferait!Mon problème:J'ai trouvé
générer des miniatures avec gd 1.6 [ par vegetaline ]
muhaha alors là c'est rigolo, un super défi pour les programmeurs fous!ok j'ai le code pour générer des miniatures grâce au php, mais ça marche qu'ave
texte sur image... librairie GD ? [ par ozitoun ]
Bonjour bonjour,voili voilou, je cherche à mettre une texte sur une image (jpeg).j'ai essayé les imagestring, imagechar... mais à chaque fois les exem
Problème d'affichage avec la libraire GD [ par CMOIPOPO ]
Salut à tous,Je souhaite dessiner tout bêtement un rectangle en php (je travaille en local) à l'aide de la libraire GD. Pour cela,
Couper le bas d'une image (GD PHP) [ par dezeque ]
bonjour,j'aimerai savoir comment faire pour couper le bas d'une image ?elle fais 600X800 et j'aimerai enlver les 50 dernirers pixels du bas pour quell
Librairie GD, Besoin d'aide !!! [ par Astalavista ]
Bon, je post ca, car je n'arrive pas a trouver ... :( Je cherche un moyen de fair un Stretch sur une image, C'est a dir de deformer
[BLOB->GD] Redimensionner un "flux image binaire"... [ par arnal69130 ]
Bonjour à tous,Je cherche à faire une page pour afficher la carte d'identité d'un "agent", pour simplifier disons juste son nom et sa p
Librairie GD [ par Stephan45120 ]
J'orai besoin de superposer 2 images. La première en arrière plan et l'autre en calque par dessus(transparente à certain endroit). Ce que je veux arri
A propos des images GD [ par ckhalilo ]
j'ai un problème d'integration des image dans un formulaire, pour eviter l'envoie automatique dans mon formulaire bref mon problème est le suivant qu
Librairie GD et perspective [ par MatiZ ]
'lutJe m'interesse un peu beaucoup à la librairie GD en ce moment et j'aurais voulu créer une perspective d'une image, mais je n'ai rien trouver. Donc
|
Téléchargements
Logiciels à télécharger sur le même thème :
|