note 98690 added to function.imagerectangle
| From: | joelv_v at hotmail dot com | Date: | Wed, 30 Jun 2010 20:42:30 +0000 |
| Subject: | note 98690 added to function.imagerectangle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170610@lists.php.net to get a copy of this message | ||
un ejemplo de gráfico de barras muy simple.
<?php
$img=imagecreate(500,500);
$fondo=imagecolorallocate($img,250,250,250);
$azul=imagecolorallocate($img,0,0,255);
$verde=imagecolorallocate($img,0,255,0);
$rojo=imagecolorallocate($img,255,0,0);
$amarillo=imagecolorallocate($img,255,255,0);
$negro=imagecolorallocate($img,0,0,0);
$gris=imagecolorallocate($img,100,100,100);
// lÃneas de ejes
// imageline ($image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
imageline($img,50,50,50,450,$negro);
imageline($img,50,450,450,450,$negro);
// lÃneas guÃa
imageline($img,50,350,450,350,$gris);
imageline($img,50,250,450,250,$gris);
imageline($img,50,150,450,150,$gris);
$a=320;
$b=240;
$c=300;
$d=210;
// barras
//imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
imagefilledrectangle($img,100,450-$a,150,450,$rojo);
imagestring($img,2,120,435-$a,$a,$negro);
imagefilledrectangle($img,200,450-$b,250,450,$azul);
imagestring($img,2,220,435-$b,$b,$negro);
imagefilledrectangle($img,300,450-$c,350,450,$verde);
imagestring($img,2,320,435-$c,$c,$negro);
imagefilledrectangle($img,400,450-$d,450,450,$amarillo);
imagestring($img,2,420,435-$d,$d,$negro);
//etiquetas del eje X
//imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color )
imagestring($img,3,120,470,"A",$rojo);
imagestring($img,3,220,470,"B",$azul);
imagestring($img,3,320,470,"C",$verde);
imagestring($img,3,420,470,"D",$amarillo);
//etiquetas del eje Y
imagestring($img,3,20,350,"100",$negro);
imagestring($img,3,20,250,"200",$negro);
imagestring($img,3,20,150,"300",$negro);
imagestring($img,3,20, 50,"400",$negro);
// titulo del gráfico
imagestring($img,5,120,20,"Gráfico de Ventas mensuales 2009",$negro);
header("Content-type: image/jpeg");
imagejpeg($img);
?>
----
Server IP: 190.2.55.64
Probable Submitter: 190.42.191.144
----
Manual Page -- http://www.php.net/manual/en/function.imagerectangle.php
Edit -- https://master.php.net/note/edit/98690
Del: integrated -- https://master.php.net/note/delete/98690/integrated
Del: useless -- https://master.php.net/note/delete/98690/useless
Del: bad code -- https://master.php.net/note/delete/98690/bad+code
Del: spam -- https://master.php.net/note/delete/98690/spam
Del: non-english -- https://master.php.net/note/delete/98690/non-english
Del: in docs -- https://master.php.net/note/delete/98690/in+docs
Del: other reasons-- https://master.php.net/note/delete/98690
Reject -- https://master.php.net/note/reject/98690
Search -- https://master.php.net/manage/user-notes.php