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

最近写的一个gd图库用以生成横竖柱状图和折线图的类库,算是一个教学例程吧 class imagereport{ var $x;//图片大小x轴 var $y;//图片大小y轴 var $r;//背影色r值 var $g;//…g. var $b;//…b. var $transparent;//是否透明1或0 var $image;//图片对像 //——————- var $arraysplit;//指定用于分隔数值的符号 var $itemarray;//数值 var $reporttype;//图表类型,1为竖柱形2为横柱形3为折线形 var $border;//距离 //——————- var $fontsize;//字体大小 var $fontcolor;//字体颜色 //——–参数设置函数 function setimage($sizex,$sizey,$r,$g,$b,$transparent){ $this->x=$sizex; $this->y=$sizey; $this->r=$r; $this->g=$g; $this->b=$b; $this->transparent=$transparent; } function setitem($arraysplit,$itemarray,$reporttype,$border){ $this->arraysplit=$arraysplit; $this->itemarray=$itemarray; $this->reporttype=$reporttype; $this->border=$border; } function setfont($fontsize){ $this->fontsize=$fontsize; } //—————-主体 function printreport(){ header( “content-type: image/gif”); //建立画布大小 $this->image=imagecreate($this->x,$this->y); //设定画布背景色 $background=imagecolorallocate($this->image,$this->r,$this->g,$this->b); if($this->transparent==”1″){ //背影透明 imagecolortransparent($this->image,$background); }else{ //如不要透明时可填充背景色 imagefilledrectangle($this->image,0,0,$this->x,$this->y,$background); } //参数字体文小及颜色 $this->fontcolor=imagecolorallocate($this->image,255-$this->r,255-$this->g,255-$this->b); switch ($this->reporttype){ case “0”: break; case “1”: $this->imagecolumns(); break; case “2”: $this->imagecolumnh(); break; case “3”: $this->imageline(); break; } $this->printxy(); $this->printall(); } //———–打印xy坐标轴 function printxy(){ //画xy坐标轴*/ $color=imagecolorallocate($this->image,255-$this->r,255-$this->g,255-$this->b); $xx=$this->x/10; $yy=$this->y-$this->y/10; imageline($this->image,$this->border,$this->border,$this->border,$this->y-$this->border,$color);//x轴 imageline($this->image,$this->border,$this->y-$this->border,$this->x-$this->border,$this->y-$this->border,$color);//y轴 //y轴上刻度 $rulery=$this->y-$this->border; while($rulery>$this->border*2){ $rulery=$rulery-$this->border; imageline($this->image,$this->border,$rulery,$this->border-2,$rulery,$color); } //x轴上刻度 $rulerx=$rulerx+$this->border; while($rulerxx-$this->border*2)){ $rulerx=$rulerx+$this->border; //imageline($this->image,$this->border,10,$this->border+10,10,$color);

http://www.bkjia.com/phpjc/508716.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/508716.htmltecharticle最近写的一个gd图库用以生成横竖柱状图和折线图的类库,算是一个教学例程吧 class imagereport var x;//图片大小x轴 var y;//图片大小y轴 var r;//背…

Posted in 未分类

发表评论