欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

利用PHP GD库绘制饼状图 不太好用

shiping1 的头像
标签: 

gd

 

php

 

it

分类: PHP

    其实PHP绘图技术还是比较简单的,大家要在利用php绘图的时候需要先配置一下,(很多童鞋在网上找了些视频,或者代码按着敲了一遍,完成之后,图片不显示,有点小郁闷,也有点打击自信心)。

   1.  首先找到php.ini文件,打开找到;extension=php_gd2.dll,这一项,去掉前面的“;”,大家千万注意要重新启动apache服务呀,不然是不会加载这项服务的。

   

<?php
//创建画布
$im=imagecreatetruecolor(200,200);
 
//默认背景颜色(黑色)
$white=imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$white);
//颜色
$red=imagecolorallocate($im,254,0,0);
$darkred=imagecolorallocate($im,144,0,0);
$blue=imagecolorallocate($im,0,0,128);
$darkblue=imagecolorallocate($im,0,0,80);
$gary=imagecolorallocate($im,192,192,192);
$darkgary=imagecolorallocate($im,144,144,144);

for($i=60;$i>=45;$i--){
 imagefilledarc($im,100,$i,100,50,0,35,$darkblue,IMG_ARC_PIE);
 imagefilledarc($im,100,$i,100,50,35,75,$darkgary,IMG_ARC_PIE);
 imagefilledarc($im,100,$i,100,50,75,360,$darkred,IMG_ARC_PIE);
}
    imagefilledarc($im,100,45,100,50,0,35,$blue,IMG_ARC_PIE);
 imagefilledarc($im,100,45,100,50,35,75,$gary,IMG_ARC_PIE);
 imagefilledarc($im,100,45,100,50,75,360,$red,IMG_ARC_PIE);
 header("content-type: image/png");
 imagepng($im);
 imagedestroy($im);

?>

来自 http://blog.sina.com.cn/s/blog_9cc667eb01012j80.html


普通分类: