php专区

 首页 > php专区 > PHP应用 > php函数大全 > php绘制柱型图的函数代码

php绘制柱型图的函数代码

分享到:
【字体:
导读:
          下面我们来看看关于php绘制柱型图的函数代码吧,好费话不说多了来看看吧,好了费话不说多了。下面我们来看看关于php绘制柱型图的函数代码吧,好费话不说多了来看看吧,好了费话不说多了。php做柱型图的函数关键

下面我们来看看关于php绘制柱型图的函数代码吧,好费话不说多了来看看吧,好了费话不说多了。
 

下面我们来看看关于php绘制柱型图的函数代码吧,好费话不说多了来看看吧,好了费话不说多了。

php做柱型图的函数

关键词:PHP

#为了方便起见,我又做了一个函数来制作柱型图
/*参数说明:
$graphdata:百分比数据(y轴)
$label:x轴标题
$data:实际数据(y轴)
$graphwidth:图像宽度
$graphheight:图像高度
$graphscale:高度因子(为$graphheight/100)
$graphfont:字体号
$bg;背景颜色值
$text:文本颜色值
$grid:边线颜色值
$bar:柱的颜色值
$bz:备注(不支持中文呀)
*/
function timage(
$graphdata,$label,$data,
$graphwidth,$graphheight,$graphscale,$graphfont,
$bg,$text,$grid,$bar,$bz)
{

header("Content-type:image/gif");
$image=imagecreate($graphwidth+50,$graphheight+50);
$bgcolor= imagecolorallocate ($image ,$bg[0],$bg[1],$bg[2]);
$textcolor= imagecolorallocate ($image ,$text[0],$text[1],$text[2]);
$gridcolor=imagecolorallocate ($image ,$grid[0],$grid[1],$grid[2]);
$barcolor=imagecolorallocate ($image ,$bar[0],$bar[1],$bar[2]);
$gridabelwidth=imagefontwidth($graphfont)*3+1;
$gridableheight= imagefontheight ($graphfont);
imageline($image,$gridlabelwidth,0,$gridlabelwidth,$graphheight-1,$gridcolor);
imageline($image,0,$graphheight-1,$graphwidth-1,$graphheight-1,$gridcolor);
for($i=0;$i<$graphheight;$i+=$graphheight/10)
{
imagedashedline ($image,0,$i,$graphwidth-1,$i,$gridcolor);
imagestring($image,$graphfont,0,$i,round(($graphheight-$i)/$graphscale),$textcolor);
}

$barwidth=(($graphwidth-$gridlabelwidth)/count($graphdata))-30;#¿ØÖÆÖùµÄ×Ü¿í¶È
for($i=0;$i {
$bartopx=$gridlabelwidth+(($i+1)*20)+($i*$barwidth);#¿ØÖÆÖù¿¿×óµÄ¾àÀë
$barbottomx=$bartopx+$barwidth;
$barbottomy=$graphheight-1;#¿ØÖÆÖùµÄϱ߽ç
$bartopy=$barbottomy-($graphdata[$i]*$graphscale);
imagefilledrectangle($image,$bartopx,$bartopy,$barbottomx,$barbottomy,$barcolor);
$labelx1=$bartopx;
$labely1=$bartopy-15;
$labelx2=$bartopx;
$labely2=$graphheight;
imagestring($image,$graphfont,$labelx1,$labely1,"$graphdata[$i]"."%",$textcolor);
imagestring($image,$graphfont,$labelx2,$labely2,"$label[$i]",$textcolor);
imagestringup ($image,$graphfont,$labelx1+10,$labely1-$gridableheight,"$data[$i]",$textcolor);
}
imagestring($image,$graphfont,1,$graphheight+30,$bz,$textcolor);
imagegif ($image);

}
?>

分享到:
php dir 函数实例教程
伪面向对象机制的阅读dir。给定的dir是开。两个属性可一旦dir已经拉开。在处理财产可以用来与其他dir功能,如readdir ( ) , rewinddir ( )和closedir ( )   dir-返回的一个实例Directory类 , 描述 dir dir( 字符串$路径; 资源$处理; 字符串改为(无效) 无效倒带(无效) 无效的密切(无效) ) 伪...
php copy 函数教程
下面来看看这款php copy 函数教程吧。   copy ( PHP 4中, PHP 5中) 复制-复制文件 描述 布尔copy(字符串$来源,字符串$ dest [ ,资源$背景] ) 使文件的一个copy源dest 。 如果你想移动的文件,请使用重新命名( )函数。 参数 来源 路径的源文件。 dest 目的地路径。如果dest是一个网址,复制操作可...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……