首页 / PHP / php动态生成饼图代码_PHP教程
php动态生成饼图代码_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php动态生成饼图代码_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2356字,纯文字阅读大概需要4分钟。
内容图文
![php动态生成饼图代码_PHP教程](/upload/InfoBanner/zyjiaocheng/181/be9e1cdf4f3c41f4952f17e066fc64d2.jpg)
//创建图像
$image=imagecreatetruecolor(300,300);
//定义画饼状图所需要的颜色
$white=imagecolorallocate($image, 0xff, 0xff, 0xff);
$gray=imagecolorallocate($image, 0xc0, 0xc0, 0xc0);
$darkgray=imagecolorallocate($image, 0x90, 0x90, 0x90);
$navy=imagecolorallocate($image, 0x00, 0x00, 0x80);
$darknavy=imagecolorallocate($image, 0x00, 0x00, 0x50);
$red=imagecolorallocate($image, 0xff, 0x00, 0x00);
$darkred=imagecolorallocate($image, 0x90, 0x00, 0x00);
/*
imagecolorallocate -- 为一幅图像分配颜色 说明 int imagecolorallocate ( resource image, int red, int green, int blue) imagecolorallocate() 返回一个标识符,代表了由给定的 rgb 成分组成的颜色。image 参数是 imagecreate() 函数的返回值。red,green 和 blue 分别是所需要的颜色的红,绿,蓝成分。这些参数是 0 到 255 的整数或者十六进制的 0x00 到 0xff。imagecolorallocate() 必须被调用以创建每一种用在 image 所代表的图像中的颜色。
*/
//画图
for($i=160;$i > 150; $i--)
{
imagefilledarc($image, 150, $i, 200, 80, 0, 45, $darknavy, img_arc_pie);
imagefilledarc($image, 150, $i, 200, 80, 45, 75 , $darkgray, img_arc_pie);
imagefilledarc($image, 150, $i, 200, 80, 75, 360 , $darkred, img_arc_pie);
}
imagefilledarc($image, 150, 150, 200, 80, 0, 45, $navy, img_arc_pie);
imagefilledarc($image, 150, 150, 200, 80, 45, 75 , $gray, img_arc_pie);
imagefilledarc($image, 150, 150, 200, 80, 75, 360 , $red, img_arc_pie);
header('content-type: image/png');
imagepng($image);
imagedestroy($image);
/*
imagefilledarc()函数,可以在画出椭圆弧的同时,使用指定颜色对其进行填充。使用此函数的这种功能,就可以很简单的画出一个用于统计的饼状图。下面演示imagefilledarc()函数的使用方法
该代码的执行结果如图22.8所示:
*/
//在图片画线条
//创建真彩色图像
$img=imagecreatetruecolor(300,300);
$white=imagecolorallocate($img,255,255,255);
$red=imagecolorallocate($img,255,0,0);
$green=imagecolorallocate($img,0,255,0);
//在图像上画椭圆
imagefilledellips教程e($img,150,150,250,100,$red);
imagefilledellipse($img,150,150,100,250,$green);
//输出图像
header("content-type: image/png");
imagepng($img);
//销毁图像
imagedestroy($img);
/*
该代码的执行结果如图22.9所示:
*/
http://www.bkjia.com/PHPjc/632996.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632996.htmlTechArticle*/ //创建图像 $image=imagecreatetruecolor(300,300); //定义画饼状图所需要的颜色 $white=imagecolorallocate($image, 0xff, 0xff, 0xff); $gray=imagecolorallocate($image,...
内容总结
以上是互联网集市为您收集整理的php动态生成饼图代码_PHP教程全部内容,希望文章能够帮你解决php动态生成饼图代码_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。