Hey Stan:
None of the other php/gd scripts work either. I have just started working
with this so at this point all I'm doing is tinkering with a bunch of
examples .
Here's one CODE example, and it gets called from <img src="bargraph.php">
in a html page.
<?php
// graph parameters
$graphwidth = 400;
$graphHeight = 200;
$graphscale = 2;
$graphfont = 5;
$graphdata =
Array("beef"=>"99","pork"=>"75","chicken"=>"15","lamb"=>"66","fish"=>"22");
$image = imagecreate($graphwidth,$graphheight) ;
imageantialias($image,true);
$colorbody = imagecolorallocate($image,255,255,255);
$colorgrid = imagecolorallocate($image,255,0,0);
$colorbar = imagecolorallocate($image,0,255,0);
$colortext = imagecolorallocate($image,0,0,255);
imagefill($image,0,0,$colorbody);
$gridlabelwidth = imagefontwidth($graphfont)*3+1;
imageline($image,$gridlabelwidth,0,$gridlabelwidth,$graphheight -
1,$colorgrid);
$styledashed =
array_merge(array_fill(0,4,$colorgrid),array_fill(0,4,IMG_COLOR_TRANSPARENT));
imagesetstyle($image,$styledashed);
for($index = 0;$index < $graphheight;$index += $graphheight/10)
{
imageline($image,0,$index,$graphwidth -
1;$index,IMG_COLOR_STYLED);
imagestring($image,$graphfont,0,$index,round(($graphheight -
$index)/$graphscale),$colortext);
}
imageline($image,0,$graphheight - 1,$graphwidth - 1,$graphheight -
1,$colorgrid);
$barwidth = (($graphwidth-$graphlabelwidth)/count($graphdata)) -
10;
$column = 0;
foreach($graphdata as $label=>$value)
{
$bartopx = $gridlabelwidth + (($column+1) + 10) + ($column
* $barwidth);
$barbottomx = $bartopx + $barwidth;
$barbottomy = $graphheight - 1;
$bartopy = $barbottomy - ($value * $graphscale);
imagefilledrectangle($image,$bartopx,$bartopy,$barbottomx,$barbottomy,$colorbar);
$labelx = $bartopx + (($barbottomx - $bartopx)/2) -
(imagefontheight($graphfont)/2);
$labely = $barbottomy - 10;
imagestringup($image,$graphfont,$labelx,$labely,"$label:
$value",$colortext);
$column++;
}
//output image
header("Content-Type: image/png");
Imagepng($image)
ImageDestroy($image);
?>
"Stan F" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> ----- Original Message -----
> From: "jm" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, December 14, 2004 3:22 AM
> Subject: [PHP] bargraph gd not working
>
>
>> Hi guys:
>> I'm using php5 on winxp with IIS. I'm trying to run a simple bar graph
> demo
>> found it on phpbuilder site. When I run it I get nothing but an x in the
> top
>> left corner of my web page(no errors nothing).
>> GD is uncommented in my php.ini, ext dir set and I have verified that GD
> is
>> installed through php -m,phpinfo() , and gd_info(). Can anyone offer me
> some
>> advice on how to troubleshoot this problem.
>> I searched google, and did see other posts like mine but no solutions.
>> Any
>> thoughts or suggestions would be appreciated
>>
>
> Do other php/gd scripts work as expected?
> (ie display images)
> Do you send the correct headers to browser?
> Please show us the code cuz without it it's not so easy to help.
>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> HTH
> Stan F
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php