下面关于php 3d饼图类绘制类函数实现原理是根据//椭圆长半轴 等参数绘制一个3d饼图形的代码。
下面关于php教程 3d饼图类绘制类函数实现原理是根据//椭圆长半轴 等参数绘制一个3d饼图形的代码。
class chart{ var $a; //椭圆长半轴 var $b; //椭圆短半轴 var $DataArray; //每个扇形的数据 var $ColorArray; //每个扇形的颜色 要求按照十六进制书写但前面不加0x //为边缘及阴影为黑色 function chart($pa=100,$pb=60,$sData="100,200,300,400,500,300", $sColor="ee00ff,dd0000,cccccc,ccff00,00ccff,ccff00") { $this->a=$pa; $this->b=$pb; $this->DataArray=split(",",$sData); $this->ColorArray=split(",",$sColor); } function setA($v){ $this->a=$v; } function getA(){ return $this->a; } function setB($v){ $this->b=$v; } function getB(){ return $this->b; } function setDataArray($v){ $this->DataArray=split(",",$v); } function getDataArray($v){ return $this->DataArray; } function setColorArray($v){ $this->ColorArray=split(",",$v); } function getColorArray(){ return $this->ColorArray; } function DrawPie(){ $image=imagecreate($this->a*2+40,$this->b*2+40); $PieCenterX=$this->a+10; $PieCenterY=$this->b+10; $DoubleA=$this->a*2; $DoubleB=$this->b*2; list($R,$G,$B)=getRGB(0); $colorBorder=imagecolorallocate($image,$R,$G,$B); $DataNumber=count($this->DataArray); //$DataTotal for($i=0;$iDataArray[$i]; //算出数据和 //填充背境 imagefill($image, 0, 0, imagecolorallocate($image, 0xFF, 0xFF, 0xFF)); /* ** 画每一个扇形 */ $Degrees = 0; for($i = 0; $i DataArray[$i]/$DataTotal)*360); $EndDegrees = round($Degrees); $percent = number_format($this->DataArray[$i]/$DataTotal*100, 1); list($R,$G,$B)=getRGB(hexdec($this->ColorArray[$i])); $CurrentColor=imagecolorallocate($image,$R,$G,$B); if ($R>60 and $R60 and $G60 and $Ba , $this->b); imageline($image,$PieCenterX,$PieCenterY,floor($PieCenterX + $ArcX),floor($PieCenterY + $ArcY),$CurrentColor); //画直线 list($ArcX, $ArcY) = pie_point($EndDegrees,$this->a , $this->b); imageline($image,$PieCenterX,$PieCenterY,ceil($PieCenterX + $ArcX),ceil($PieCenterY + $ArcY),$CurrentColor); //填充扇形 $MidPoint = round((($EndDegrees - $StartDegrees)/2) + $StartDegrees); list($ArcX, $ArcY) = Pie_point($MidPoint, $this->a*3/4 , $this->b*3/4); imagefilltoborder($image,floor($PieCenterX + $ArcX),floor($PieCenterY + $ArcY), $CurrentColor,$CurrentColor); imagestring($image,2,floor($PieCenterX + $ArcX-5),floor($PieCenterY + $ArcY-5),$percent."%",$colorBorder); //画阴影 if ($StartDegrees>=0 and $StartDegrees
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号