80,250,430,134,35,60,233,90,263,225,120,59,151,677,340,221,550,300,229,97,230,123,133,87一共24个数字一个都不能少哦少了要出错你可以修改函数判断一下 <div class="codetitle"><a style="CURSOR: pointer" data="28252" class="copybut" id="copybut28252" onclick="doCopy('code28252')"> 代码如下:<div class="codebody" id="code28252"> <?PHP / 24小时柱状图 作者:taokey QQ:29611705 / functionh24($str){ $hour=explode(",",$str); $hmax=max($hour); $ppix=150/$hmax; //计算柱状图高度 $h0=190-$hour[0]$ppix; $h1=190-$hour[1]$ppix; $h2=190-$hour[2]$ppix; $h3=190-$hour[3]$ppix; $h4=190-$hour[4]$ppix; $h5=190-$hour[5]$ppix; $h6=190-$hour[6]$ppix; $h7=190-$hour[7]$ppix; $h8=190-$hour[8]$ppix; $h9=190-$hour[9]$ppix; $h10=190-$hour[10]$ppix; $h11=190-$hour[11]$ppix; $h12=190-$hour[12]$ppix; $h13=190-$hour[13]$ppix; $h14=190-$hour[14]$ppix; $h15=190-$hour[15]$ppix; $h16=190-$hour[16]$ppix; $h17=190-$hour[17]$ppix; $h18=190-$hour[18]$ppix; $h19=190-$hour[19]$ppix; $h20=190-$hour[20]$ppix; $h21=190-$hour[21]$ppix; $h22=190-$hour[22]$ppix; $h23=190-$hour[23]$ppix; //创建一个img $img=imagecreate(755,210); //背景 $bgc=imagecolorallocate($img,245,254); //黑色 $bc=imagecolorallocate($img,0); //画竖轴 imageline($img,15,30,189,$bc); //画横轴 imageline($img,190,750,$bc); //画竖轴点 for($i=39,$j=10;$i<189;$i=$i+15,$j--){ imageline($img,13,$i,$bc); imagestring($img,1,$i-4,$j."x",$bc); } //画横轴点 $t=true; for($i=31,$j=29;$i<750;$i=$j+1,$j=$j+15){ if($t){ $x=$i; $t=false; }else{ $x=$i+1; $t=true; } imageline($img,$x,192,$bc); } //竖轴标记 $x=ceil($hmax/10); imagestring($img,2,10,"X=".$x,$bc); //竖轴标记 //0点 $color=imagecolorallocate($img,mt_rand(0,255),255)); imagefilledrectangle($img,31,$h0,45,$color); imagestring($img,$h0-10,$hour[0],$color); imagechar($img,36,195,$bc); //1点 $color=imagecolorallocate($img,61,$h1,75,$h1-10,$hour[1],66,$bc); //2点 $color=imagecolorallocate($img,91,$h2,105,$h2-10,$hour[2],96,$bc); //3点 $color=imagecolorallocate($img,121,$h3,135,$h3-10,$hour[3],126,3,$bc); //4点 $color=imagecolorallocate($img,$h4,165,$h4-10,$hour[4],156,4,$bc); //5点 $color=imagecolorallocate($img,181,$h5,$h5-10,$hour[5],186,5,$bc); //6点 $color=imagecolorallocate($img,211,$h6,$h6-10,$hour[6],216,6,$bc); //7点 $color=imagecolorallocate($img,241,$h7,255,$h7-10,$hour[7],246,7,$bc); //8点 $color=imagecolorallocate($img,271,$h8,285,$h8-10,$hour[8],276,8,$bc); //9点 $color=imagecolorallocate($img,301,$h9,315,$h9-10,$hour[9],306,9,$bc); //10点 $color=imagecolorallocate($img,331,$h10,345,$h10-10,$hour[10],334,$bc); //11点 $color=imagecolorallocate($img,361,$h11,375,$h11-10,$hour[11],364,11,$bc); //12点 $color=imagecolorallocate($img,391,$h12,405,$h12-10,$hour[12],394,12,$bc); //13点 $color=imagecolorallocate($img,421,$h13,435,$h13-10,$hour[13],424,$bc); //14点 $color=imagecolorallocate($img,451,$h14,465,$h14-10,$hour[14],454,14,$bc); //15点 $color=imagecolorallocate($img,481,$h15,495,$h15-10,$hour[15],$bc); //16点 $color=imagecolorallocate($img,511,$h16,525,$h16-10,$hour[16],16,$bc); //17点 $color=imagecolorallocate($img,541,$h17,555,$h17-10,$hour[17],544,17,$bc); //18点 $color=imagecolorallocate($img,571,$h18,585,$h18-10,$hour[18],18,$bc); //19点 $color=imagecolorallocate($img,601,$h19,615,$h19-10,$hour[19],604,19,$bc); //20点 $color=imagecolorallocate($img,631,$h20,645,$h20-10,$hour[20],634,20,$bc); //21点 $color=imagecolorallocate($img,661,$h21,675,$h21-10,$hour[21],664,21,$bc); //22点 $color=imagecolorallocate($img,691,$h22,705,$h22-10,$hour[22],694,22,$bc); //23点 $color=imagecolorallocate($img,721,$h23,735,$h23-10,$hour[23],724,23,$bc); //加个边框加了之后不好看 //imagerectangle($img,754,209,$bc); imagepng($img); imagedestroy($img); } $str=isset($_GET['str'])?$_GET['str']:""; if($str){ h24($str); } ?>
(编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|