设为首页收藏本站language→→ 语言切换

鸿鹄论坛

 找回密码
 论坛注册

QQ登录

先注册再绑定QQ

查看: 1599|回复: 0
收起左侧

用gd图库生成横竖柱状图折线图的类

[复制链接]
发表于 2010-2-24 13:43:52 | 显示全部楼层 |阅读模式
<OL><LI><CODE><FONT face=新宋体>&lt;?最近写的一个GD图库用以生成横竖柱状图和折线图的类库,算是一个教学例程吧  </FONT></CODE><LI><CODE><FONT face=新宋体>Class ImageReport{ </FONT></CODE><LI><CODE><FONT face=新宋体>var $X;//图片大小X轴 </FONT></CODE><LI><CODE><FONT face=新宋体>var $Y;//图片大小Y轴 </FONT></CODE><LI><CODE><FONT face=新宋体>var $R;//背影色R值 </FONT></CODE><LI><CODE><FONT face=新宋体>var $G;//...G. </FONT></CODE><LI><CODE><FONT face=新宋体>var $B;//...B. </FONT></CODE><LI><CODE><FONT face=新宋体>var $TRANSPARENT;//是否透明1或0 </FONT></CODE><LI><CODE><FONT face=新宋体>var $IMAGE;//图片对像 </FONT></CODE><LI><CODE><FONT face=新宋体>//------------------- </FONT></CODE><LI><CODE><FONT face=新宋体>var $ARRAYSPLIT;//指定用于分隔数值的符号 </FONT></CODE><LI><CODE><FONT face=新宋体>var $ITEMARRAY;//数值 </FONT></CODE><LI><CODE><FONT face=新宋体>var $REPORTTYPE;//图表类型,1为竖柱形2为横柱形3为折线形 </FONT></CODE><LI><CODE><FONT face=新宋体>var $BORDER;//距离 </FONT></CODE><LI><CODE><FONT face=新宋体>//------------------- </FONT></CODE><LI><CODE><FONT face=新宋体>var $FONTSIZE;//字体大小 </FONT></CODE><LI><CODE><FONT face=新宋体>var $FONTCOLOR;//字体颜色 </FONT></CODE><LI><CODE><FONT face=新宋体>//--------参数设置函数 </FONT></CODE><LI><CODE><FONT face=新宋体>function setImage($SizeX,$SizeY,$R,$G,$B,$Transparent){ </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;X=$SizeX;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;Y=$SizeY;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;R=$R;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;G=$G;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;B=$B;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;TRANSPARENT=$Transparent;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>function setItem($ArraySplit,$ItemArray,$ReportType,$Border){  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;ARRAYSPLIT=$ArraySplit;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;ITEMARRAY=$ItemArray;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;REPORTTYPE=$ReportType;  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;BORDER=$Border;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>function setFont($FontSize){  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;FONTSIZE=$FontSize;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>//----------------主体  </FONT></CODE><LI><CODE><FONT face=新宋体>function PrintReport(){  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.Header"><FONT face=新宋体 color=#0000ff><U>Header</U></FONT></A><FONT face=新宋体>( "Content-type: image/gif");  </FONT></CODE><LI><CODE><FONT face=新宋体>//建立画布大小  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;IMAGE=<A href="http://www.php.net/manual/zh/function.ImageCreate"><U><FONT color=#0000ff>ImageCreate</FONT></U></A>($this-&gt;X,$this-&gt;Y);  </FONT></CODE><LI><CODE><FONT face=新宋体>//设定画布背景色  </FONT></CODE><LI><CODE><FONT face=新宋体>$background=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,$this-&gt;R,$this-&gt;G,$this-&gt;B);  </FONT></CODE><LI><CODE><FONT face=新宋体>if($this-&gt;TRANSPARENT=="1"){  </FONT></CODE><LI><CODE><FONT face=新宋体>//背影透明  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.Imagecolortransparent"><FONT face=新宋体 color=#0000ff><U>Imagecolortransparent</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$background);  </FONT></CODE><LI><CODE><FONT face=新宋体>}else{  </FONT></CODE><LI><CODE><FONT face=新宋体>//如不要透明时可填充背景色  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageFilledRectangle"><FONT face=新宋体 color=#0000ff><U>ImageFilledRectangle</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,0,0,$this-&gt;X,$this-&gt;Y,$background);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>//参数字体文小及颜色  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;FONTCOLOR=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,255-$this-&gt;R,255-$this-&gt;G,255-$this-&gt;B);  </FONT></CODE><LI><CODE><FONT face=新宋体>Switch ($this-&gt;REPORTTYPE){  </FONT></CODE><LI><CODE><FONT face=新宋体>case "0":  </FONT></CODE><LI><CODE><FONT face=新宋体>break;  </FONT></CODE><LI><CODE><FONT face=新宋体>case "1":  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;imageColumnS();  </FONT></CODE><LI><CODE><FONT face=新宋体>break;  </FONT></CODE><LI><CODE><FONT face=新宋体>case "2":  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;imageColumnH();  </FONT></CODE><LI><CODE><FONT face=新宋体>break;  </FONT></CODE><LI><CODE><FONT face=新宋体>case "3":  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;<A href="http://www.php.net/manual/zh/function.imageLine"><U><FONT color=#0000ff>imageLine</FONT></U></A>();  </FONT></CODE><LI><CODE><FONT face=新宋体>break;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;printXY();  </FONT></CODE><LI><CODE><FONT face=新宋体>$this-&gt;printAll();  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>//-----------打印XY坐标轴  </FONT></CODE><LI><CODE><FONT face=新宋体>function printXY(){  </FONT></CODE><LI><CODE><FONT face=新宋体>//画XY坐标轴*/  </FONT></CODE><LI><CODE><FONT face=新宋体>$color=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,255-$this-&gt;R,255-$this-&gt;G,255-$this-&gt;B);  </FONT></CODE><LI><CODE><FONT face=新宋体>$xx=$this-&gt;X/10;  </FONT></CODE><LI><CODE><FONT face=新宋体>$yy=$this-&gt;Y-$this-&gt;Y/10;  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageLine"><FONT face=新宋体 color=#0000ff><U>ImageLine</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;BORDER,$this-&gt;BORDER,$this-&gt;BORDER,$this-&gt;Y-$this-&gt;BORDER,$color);//X轴  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageLine"><FONT face=新宋体 color=#0000ff><U>ImageLine</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;BORDER,$this-&gt;Y-$this-&gt;BORDER,$this-&gt;X-$this-&gt;BORDER,$this-&gt;Y-$this-&gt;BORDER,$color);//y轴  </FONT></CODE><LI><CODE><FONT face=新宋体>//Y轴上刻度  </FONT></CODE><LI><CODE><FONT face=新宋体>$rulerY=$this-&gt;Y-$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>while($rulerY&gt;$this-&gt;BORDER*2){  </FONT></CODE><LI><CODE><FONT face=新宋体>$rulerY=$rulerY-$this-&gt;BORDER;  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageLine"><FONT face=新宋体 color=#0000ff><U>ImageLine</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;BORDER,$rulerY,$this-&gt;BORDER-2,$rulerY,$color);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>//X轴上刻度  </FONT></CODE><LI><CODE><FONT face=新宋体>$rulerX=$rulerX+$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>while($rulerX&lt;($this-&gt;X-$this-&gt;BORDER*2)){  </FONT></CODE><LI><CODE><FONT face=新宋体>$rulerX=$rulerX+$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>//ImageLine($this-&gt;IMAGE,$this-&gt;BORDER,10,$this-&gt;BORDER+10,10,$color);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageLine"><FONT face=新宋体 color=#0000ff><U>ImageLine</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$rulerX,$this-&gt;Y-$this-&gt;BORDER,$rulerX,$this-&gt;Y-$this-&gt;BORDER+2,$color);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><LI><CODE><FONT face=新宋体>//--------------竖柱形图  </FONT></CODE><LI><CODE><FONT face=新宋体>function imageColumnS(){  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_array=<A href="http://www.php.net/manual/zh/function.Split"><U><FONT color=#0000ff>Split</FONT></U></A>($this-&gt;ARRAYSPLIT,$this-&gt;ITEMARRAY);  </FONT></CODE><LI><CODE><FONT face=新宋体>$num=<A href="http://www.php.net/manual/zh/function.Count"><U><FONT color=#0000ff>Count</FONT></U></A>($item_array);  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=0;  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=<A href="http://www.php.net/manual/zh/function.Max"><U><FONT color=#0000ff>Max</FONT></U></A>($item_max,$item_array[$i]); </FONT></CODE><LI><CODE><FONT face=新宋体>} </FONT></CODE><LI><CODE><FONT face=新宋体>$xx=$this-&gt;BORDER*2;  </FONT></CODE><LI><CODE><FONT face=新宋体>//画柱形图  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.srand"><FONT face=新宋体 color=#0000ff><U>srand</U></FONT></A><FONT face=新宋体>((double)<A href="http://www.php.net/manual/zh/function.microtime"><U><FONT color=#0000ff>microtime</FONT></U></A>()*1000000); </FONT></CODE><LI><CODE><FONT face=新宋体>if($this-&gt;R!=255 &amp;&amp; $this-&gt;G!=255 &amp;&amp; $this-&gt;B!=255){  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;R,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;G,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;B,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}else{  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>$color=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,$R,$G,$B);  </FONT></CODE><LI><CODE><FONT face=新宋体>//柱形高度  </FONT></CODE><LI><CODE><FONT face=新宋体>$height=($this-&gt;Y-$this-&gt;BORDER)-($this-&gt;Y-$this-&gt;BORDER*2)*($item_array[$i]/$item_max);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageFilledRectangle"><FONT face=新宋体 color=#0000ff><U>ImageFilledRectangle</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$xx,$height,$xx+$this-&gt;BORDER,$this-&gt;Y-$this-&gt;BORDER,$color);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageString"><FONT face=新宋体 color=#0000ff><U>ImageString</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;FONTSIZE,$xx,$height-$this-&gt;BORDER,$item_array[$i],$this-&gt;FONTCOLOR);  </FONT></CODE><LI><CODE><FONT face=新宋体>//用于间隔  </FONT></CODE><LI><CODE><FONT face=新宋体>$xx=$xx+$this-&gt;BORDER*2;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><LI><CODE><FONT face=新宋体>//-----------横柱形图  </FONT></CODE><LI><CODE><FONT face=新宋体>function imageColumnH(){  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_array=<A href="http://www.php.net/manual/zh/function.Split"><U><FONT color=#0000ff>Split</FONT></U></A>($this-&gt;ARRAYSPLIT,$this-&gt;ITEMARRAY);  </FONT></CODE><LI><CODE><FONT face=新宋体>$num=<A href="http://www.php.net/manual/zh/function.Count"><U><FONT color=#0000ff>Count</FONT></U></A>($item_array);  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=0;  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=<A href="http://www.php.net/manual/zh/function.Max"><U><FONT color=#0000ff>Max</FONT></U></A>($item_max,$item_array[$i]); </FONT></CODE><LI><CODE><FONT face=新宋体>} </FONT></CODE><LI><CODE><FONT face=新宋体>$yy=$this-&gt;Y-$this-&gt;BORDER*2;  </FONT></CODE><LI><CODE><FONT face=新宋体>//画柱形图  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.srand"><FONT face=新宋体 color=#0000ff><U>srand</U></FONT></A><FONT face=新宋体>((double)<A href="http://www.php.net/manual/zh/function.microtime"><U><FONT color=#0000ff>microtime</FONT></U></A>()*1000000); </FONT></CODE><LI><CODE><FONT face=新宋体>if($this-&gt;R!=255 &amp;&amp; $this-&gt;G!=255 &amp;&amp; $this-&gt;B!=255){  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;R,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;G,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;B,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}else{  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>$color=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,$R,$G,$B);  </FONT></CODE><LI><CODE><FONT face=新宋体>//柱形长度  </FONT></CODE><LI><CODE><FONT face=新宋体>$leight=($this-&gt;X-$this-&gt;BORDER*2)*($item_array[$i]/$item_max);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageFilledRectangle"><FONT face=新宋体 color=#0000ff><U>ImageFilledRectangle</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;BORDER,$yy-$this-&gt;BORDER,$leight,$yy,$color);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageString"><FONT face=新宋体 color=#0000ff><U>ImageString</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;FONTSIZE,$leight+2,$yy-$this-&gt;BORDER,$item_array[$i],$this-&gt;FONTCOLOR);  </FONT></CODE><LI><CODE><FONT face=新宋体>//用于间隔  </FONT></CODE><LI><CODE><FONT face=新宋体>$yy=$yy-$this-&gt;BORDER*2;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><LI><CODE><FONT face=新宋体>//--------------折线图  </FONT></CODE><LI><CODE><FONT face=新宋体>function <A href="http://www.php.net/manual/zh/function.imageLine"><U><FONT color=#0000ff>imageLine</FONT></U></A>(){  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_array=<A href="http://www.php.net/manual/zh/function.Split"><U><FONT color=#0000ff>Split</FONT></U></A>($this-&gt;ARRAYSPLIT,$this-&gt;ITEMARRAY);  </FONT></CODE><LI><CODE><FONT face=新宋体>$num=<A href="http://www.php.net/manual/zh/function.Count"><U><FONT color=#0000ff>Count</FONT></U></A>($item_array);  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=0;  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><FONT face=新宋体>$item_max=<A href="http://www.php.net/manual/zh/function.Max"><U><FONT color=#0000ff>Max</FONT></U></A>($item_max,$item_array[$i]); </FONT></CODE><LI><CODE><FONT face=新宋体>} </FONT></CODE><LI><CODE><FONT face=新宋体>//$xx=$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>//画柱形图  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.srand"><FONT face=新宋体 color=#0000ff><U>srand</U></FONT></A><FONT face=新宋体>((double)<A href="http://www.php.net/manual/zh/function.microtime"><U><FONT color=#0000ff>microtime</FONT></U></A>()*1000000); </FONT></CODE><LI><CODE><FONT face=新宋体>if($this-&gt;R!=255 &amp;&amp; $this-&gt;G!=255 &amp;&amp; $this-&gt;B!=255){  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;R,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;G,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>($this-&gt;B,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}else{  </FONT></CODE><LI><CODE><FONT face=新宋体>$R=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$G=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>$B=<A href="http://www.php.net/manual/zh/function.Rand"><U><FONT color=#0000ff>Rand</FONT></U></A>(50,200);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>$color=<A href="http://www.php.net/manual/zh/function.ImageColorAllocate"><U><FONT color=#0000ff>ImageColorAllocate</FONT></U></A>($this-&gt;IMAGE,$R,$G,$B);  </FONT></CODE><LI><CODE><FONT face=新宋体>//柱形高度  </FONT></CODE><LI><CODE><FONT face=新宋体>$height_now=($this-&gt;Y-$this-&gt;BORDER)-($this-&gt;Y-$this-&gt;BORDER*2)*($item_array[$i]/$item_max);  </FONT></CODE><LI><CODE><FONT face=新宋体>if($i!="0"){  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageLine"><FONT face=新宋体 color=#0000ff><U>ImageLine</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$xx,$height_next,$xx+$this-&gt;BORDER,$height_now,$color);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageString"><FONT face=新宋体 color=#0000ff><U>ImageString</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE,$this-&gt;FONTSIZE,$xx+$this-&gt;BORDER,$height_now-$this-&gt;BORDER/2,$item_array[$i],$this-&gt;FONTCOLOR);  </FONT></CODE><LI><CODE><FONT face=新宋体>$height_next=$height_now;  </FONT></CODE><LI><CODE><FONT face=新宋体>//用于间隔  </FONT></CODE><LI><CODE><FONT face=新宋体>$xx=$xx+$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><LI><CODE><FONT face=新宋体>//--------------完成打印图形http://knowsky.com  </FONT></CODE><LI><CODE><FONT face=新宋体>function printAll(){  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageGIF"><FONT face=新宋体 color=#0000ff><U>ImageGIF</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE);  </FONT></CODE><LI><CODE><A href="http://www.php.net/manual/zh/function.ImageDestroy"><FONT face=新宋体 color=#0000ff><U>ImageDestroy</U></FONT></A><FONT face=新宋体>($this-&gt;IMAGE);  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>//--------------调试  </FONT></CODE><LI><CODE><FONT face=新宋体>function debug(){  </FONT></CODE><LI><CODE><FONT face=新宋体>echo "X:".$this-&gt;X."</FONT></CODE><LI><CODE><FONT face=新宋体>Y:".$this-&gt;Y;  </FONT></CODE><LI><CODE><FONT face=新宋体>echo "</FONT></CODE><LI><CODE><FONT face=新宋体>BORDER:".$this-&gt;BORDER;  </FONT></CODE><LI><CODE><FONT face=新宋体>$item_array=<A href="http://www.php.net/manual/zh/function.split"><U><FONT color=#0000ff>split</FONT></U></A>($this-&gt;ARRAYSPLIT,$this-&gt;ITEMARRAY);  </FONT></CODE><LI><CODE><FONT face=新宋体>$num=<A href="http://www.php.net/manual/zh/function.Count"><U><FONT color=#0000ff>Count</FONT></U></A>($item_array);  </FONT></CODE><LI><CODE><FONT face=新宋体>echo "</FONT></CODE><LI><CODE><FONT face=新宋体>数值个数:".$num."</FONT></CODE><LI><CODE><FONT face=新宋体>数值:";  </FONT></CODE><LI><CODE><FONT face=新宋体>for ($i=0;$i&lt;$num;$i++){ </FONT></CODE><LI><CODE><FONT face=新宋体>echo "</FONT></CODE><LI><CODE><FONT face=新宋体>".$item_array[$i];  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><CODE><FONT face=新宋体>}  </FONT></CODE><LI><LI><CODE><FONT face=新宋体>$report=new ImageReport;  </FONT></CODE><LI><CODE><FONT face=新宋体>$report-&gt;setImage(600,300,255,255,255,1);//参数(长,宽,背影色R,G,B,是否透明1或0)  </FONT></CODE><LI><CODE><FONT face=新宋体>$temparray="50,25,100,250,180,200,150,220,200,150,50,25,100,250,180,200,150,220,200,150";//数值,用指定符号隔开  </FONT></CODE><LI><CODE><FONT face=新宋体>$report-&gt;setItem(',',$temparray,3,20);//参数(分隔数值的指定符号,数值变量,样式1为竖柱图2为横柱图3为折线图,距离)  </FONT></CODE><LI><CODE><FONT face=新宋体>$report-&gt;setFont(1);//字体大小1-10  </FONT></CODE><LI><CODE><FONT face=新宋体>$report-&gtrintReport();  </FONT></CODE><LI><CODE><FONT face=新宋体>//$report-&gt;debug();//调式之用  </FONT></CODE><LI><CODE><FONT face=新宋体>?&gt;</FONT></CODE></LI></OL>
您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2024-4-20 05:24 , Processed in 0.058557 second(s), 9 queries , Redis On.  

  Powered by Discuz!

  © 2001-2024 HH010.COM

快速回复 返回顶部 返回列表