通行证: 用户 密码 域名空间  下载中心 社区论坛 信息公告 my小屋
联系我们
设为首页
加入收藏

 

qq,asp,php,jsp,xml,sql,.net,编程 程序 网页图象 建站经验 私服
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿
论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图
专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版
社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务
当前位置:首页>>在线服务>>疑难解答>>正文 新版上线![旧版]
注:打开慢时请稍等

显示饼图的问题

http://www.iyit.net  日期:2006-10-6 15:37:11  来源:iyit.net收集  点击:
参加讨论
显示饼图正常,只是将vote2和vote3不能分开,两种颜色混淆了,只显示vote2的颜色,vote3黄色显示为vote2的橙色,大家帮忙看看  
 
查看饼图url:  
http://localhost/poll/voteimg.php?vote1=1&vote2=1&vote3=1&vote4=1&vote5=1  
通过get方法传递值  
 
 
代码:  
<?php  
$vote1  =  $_get['vote1'];  
$vote2  =  $_get['vote2'];  
$vote3  =  $_get['vote3'];  
$vote4  =  $_get['vote4'];  
$vote5  =  $_get['vote5'];  
$votez  =  $vote1+$vote2+$vote3+$vote4+$vote5;  
if($vote1>0){  
   $vote1a  =  $vote1/$votez*360;  
}  
else{  
   $vote1a  =  0;  
}  
if($vote2>0){  
   $vote2a  =  $vote2/$votez*360;  
}  
else{  
   $vote2a  =  0;  
}  
if($vote3>0){  
   $vote3a  =  $vote3/$votez*360;  
}  
else{  
   $vote3a  =  0;  
}  
if($vote4>0){  
   $vote4a  =  $vote4/$votez*360;  
}  
else{  
   $vote4a  =  0;  
}  
if($vote5>0){  
   $vote5a  =  $vote5/$votez*360;  
}  
else{  
   $vote5a  =  0;  
}  
$img_output=imagecreate(188,170);  
$color0a  =  imagecolorallocate($img_output,255,255,255);  //白色  
$color0b  =  imagecolorallocate($img_output,0,0,0);              //黑色  
$color1a  =  imagecolorallocate($img_output,255,0,0);          //红色a  
$color1b  =  imagecolorallocate($img_output,200,0,0);          //红色b  
$color2a  =  imagecolorallocate($img_output,255,128,64);    //橙色a  
$color2b  =  imagecolorallocate($img_output,198,64,0);        //橙色b  
$color3a  =  imagecolorallocate($img_output,255,255,0);      //黄色a  
$color3b  =  imagecolorallocate($img_output,200,200,0);      //黄色b  
$color4a  =  imagecolorallocate($img_output,133,248,18);    //绿色a  
$color4b  =  imagecolorallocate($img_output,0,200,0);          //绿色b  
$color5a  =  imagecolorallocate($img_output,0,0,255);          //蓝色a  
$color5b  =  imagecolorallocate($img_output,0,0,200);          //蓝色b  
imagecolortransparent($img_output,$color0a);  
$picture_x  =  93;  
$picture_y  =  80;  
$picture_w  =  180;  
$picture_h  =  140;  
for($temp_a=$picture_y+11;$temp_a>$picture_y;$temp_a--){  
   if($vote5>0){  
       for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
           imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,0,$vote5a,$color5b);  
       }  
   }  
   if($vote4>0){  
       for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
           imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a,$vote5a+$vote4a,$color4b);  
       }  
   }  
   if($vote3>0){  
       for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
           imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a,$vote5a+$vote4a+$vote3a,$color3b);  
       }  
   }  
   if($vote2>0){  
       for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
           imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a+vote3a,$vote5a+$vote4a+$vote3a+$vote2a,$color2b);  
       }  
   }  
   if($vote1>0){  
       for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
           imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a+$vote2a,360,$color1b);  
       }  
   }  
}  
if($vote5>0){  
   for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
       imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,0,$vote5a,$color5a);  
   }  
}  
if($vote4>0){  
   for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
       imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a,$vote5a+$vote4a,$color4a);  
   }  
}  
if($vote3>0){  
   for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
       imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a,$vote5a+$vote4a+$vote3a,$color3a);  
   }  
}  
if($vote2>0){  
   for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
       imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a+vote3a,$vote5a+$vote4a+$vote3a+$vote2a,$color2a);  
   }  
}  
if($vote1>0){  
   for($temp_b=$picture_w;$temp_b>0;$temp_b--){  
       imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a+$vote2a,360,$color1a);  
   }  
}  
header("content-type:  image/png");  
imagepng($img_output);  
imagedestroy($img_output);    
?>  
---------------------------------------------------------------  
你的算法太烦琐了  
饼图是由多个扇形组成的。  
画扇形是这样的:  
1、画一弧  
2、求出该弧在圆周上的两个端点的坐标  
3、分别从圆心到弧的端点画线  
4、视需要充填该区域  
---------------------------------------------------------------  
可以参考这个:http://unix.1816.net/bbs/read.php?fid=1&tid=12&fpage=2  
<?php  
class  biscuitpicture3d//类名称  
{  
var  $image;  
var  $width;  
var  $height;  
var  $x;  
var  $y;  
var  $z;  
var  $font;  
var  $percents;  
var  $darkcolors;  
var  $lightcolors;  
function  biscuitpicture3d(  $width,  $height,  $width3d,  $height3d,  $startx,  $starty,  $startz  ){  
$this->image  =  imagecreate(  $width,  $height  );  
$white  =  imagecolorallocate(  $this->image,  0xff,  0xff,  0xff  );  
$this->width  =  $width3d;  
$this->height  =  $height3d;  
$this->x  =  $startx;  
$this->y  =  $starty;  
$this->z  =  $startz;  
$this->font  =  '/var/www/simsun.ttc'  
}  
function  drawpic(){  
$i  =  0;  
while(  isset($this->percents[$i])  ){  
$this->percents[$i]  =  360  *  $this->percents[$i]  /  100;  
$i++;  
}  
for  (  $i  =  $this->y;  $i  >  $this->y  -  $this->z;  $i--  ){  
$j  =  0;  
while(  isset($this->percents[$j+1])  ){  
if  (  $j  ==  0  ){  
imagefilledarc(  $this->image,  $this->x,  $i,  $this->width,  $this->height,  0,  $this->percents[$j],  $this->darkcolors[$j],  img_arc_pie  );  
}  
else{  
$startpos  =  0;  
for(  $temp  =  0;  $temp  <  $j;  $temp++  ){  
$startpos  =  $startpos  +  $this->percents[$temp];  
}  
imagefilledarc(  $this->image,  $this->x,  $i,  $this->width,  $this->height,  $startpos,  $this->percents[$j]+$startpos,  $this->darkcolors[$j],  img_arc_pie  );  
}  
$j++;  
}  
imagefilledarc(  $this->image,  $this->x,  $i,  $this->width,  $this->height,  360-$this->percents[$j],  360,  $this->darkcolors[$j],  img_arc_pie  );  
}  
$j  =  0;  
while(  isset($this->percents[$j+1])  ){  
if  (  $j  ==  0  ){  
imagefilledarc(  $this->image,  $this->x,  $this->y-$this->z,  $this->width,  $this->height,  0,  $this->percents[$j],  $this->lightcolors[$j],  img_arc_pie  );  
}  
else{  
$startpos  =  0;  
for(  $temp  =  0;  $temp  <  $j;  $temp++  ){  
$startpos  =  $startpos  +  $this->percents[$temp];  
}  
imagefilledarc(  $this->image,  $this->x,  $this->y-$this->z,  $this->width,  $this->height,  $startpos,  $this->percents[$j]+$startpos,  $this->lightcolors[$j],  img_arc_pie  );  
}  
$j++;  
}  
imagefilledarc(  $this->image,  $this->x,  $this->y-$this->z,  $this->width,  $this->height,  360-$this->percents[$j],  360,  $this->lightcolors[$j],  img_arc_pie  );  
}  
function  showpic(){  
header('content-type:  image/png');  
imagepng(  $this->image  );  
imagedestroy(  $this->image  );  
}  
function  additem(  $percent,  $r1,  $g1,  $b1,  $r2,  $g2,  $b2  ){  
$this->percents[]  =  $percent;  
$this->darkcolors[]  =  imagecolorallocate(  $this->image,  $r1,  $g1,  $b1  );  
$this->lightcolors[]  =  imagecolorallocate(  $this->image,  $r2,  $g2,  $b2  );  
}  
function  writechinese(  $str,  $fontsize,  $startx,  $starty,  $r,  $g,  $b  ){  
$str  =  iconv(  "gb2312",  "utf-8",  $str  );  
$color  =  imagecolorallocate(  $this->image,  $r,  $g,  $b  );  
imagettftext(  $this->image,  $fontsize,  0,  $startx,  $starty,  $color,  $this->font,  $str  );}  
}  
$picwidth  =  400;  
$picheight  =  400;  
$width3d  =  300;  
$height3d  =  100;  
$x  =  $picwidth  /  2;  
$y  =  $picheight  /  2;  
$z  =  40;  
$b  =  new  biscuitpicture3d(  $picwidth,  $picheight,  $width3d,  $height3d,  $x,  $y,  $z  );  
$b->additem(  10,  0x90,  0x00,  0x00,  0xff,  0x00,  0x00  );  
$b->additem(  15,  0xe1,  0xe1,  0x00,  0xff,  0xff,  0x00  );  
$b->additem(  20,  0x00,  0x00,  0x50,  0x00,  0x00,  0x80  );  
$b->additem(  25,  0x90,  0x90,  0x90,  0xc0,  0xc0,  0xc0  );  
$b->additem(  30,  16,  185,  35,  16,  208,  35  );  
$b->drawpic();  
$b->writechinese(  '3d饼状图',  22,  150,  350,  0,  0,  0  );  
$b->showpic();  
?>  


编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部]
上一篇:一棵可以实现无限分类的类树
下一篇:关于多层目录中文件嵌套引用的问题。。。。。。。。。。。。。。。。。
转载请注明来源:www.iyit.net
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

 相关文章
最新更新 热点排行 推荐新闻
我在windows  xp上安装apache2.044+ph
apache+php,怎样打开session支持??
在linux中怎么配置pdflib和php  高分!
怎么样同时解释.php和.php3的文件呀,
php 4.1.0 及以后版本使用post变量的接
我的qq被盗走的原因分析
webqq好玩不?大鸟带你一起体验
奇奇怪怪的qq密技十五招
qq被盗到出售过程详解
微软winxp sp3再次跳票 推至08年发布
google苹果合作浏览器 防恶意网站
微软操作系统实现开源?
网管应当如何管理windows操作系统?
让windows xp系统锁定期间拒绝关机
windowsvista中文版11月30日正式发布
我在windows  xp上安装apache2.044+ph
php 在linux 下如何開啟ftp功能
apache2-win32+php的成功安装方法
怎么删除mysql???
apache+php,怎样打开session支持??
合并vcd片断、快速删除文件夹--dos命令
dos教程 dos命令基础应用
破解qq密码如此简单 
低格、分区、高格的应对--dos命令应用
一劳永逸--批处理命令(一)
qq2006 beta3隆重发布 实用功能一一奉
美国微软总部相中重庆15岁网络奇才(图
qq号码激活的常见问题及案例分析 
sql server安装文件挂起错误解决办法
三分钟让你的系统变处女:acronis tru
exeplorer.exe错误的问题的总结、解决
我的qq被盗走的原因分析
webqq好玩不?大鸟带你一起体验
奇奇怪怪的qq密技十五招
qq被盗到出售过程详解
google苹果合作浏览器 防恶意网站
网管应当如何管理windows操作系统?
让windows xp系统锁定期间拒绝关机
windowsvista中文版11月30日正式发布
google优化网站管理员指导方针
hilltop算法- 探索google排名新算法

设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
copyrights © 2004-2006 iyit.net all rights reserved.
网站合作、广告联系qq:147007642、466949678
易特网络技术 点击这里给我发消息