易截截图软件、单文件、免安装、纯绿色、仅160KB

php绘制饼状图

drawPieImg()函数包含8个参数,$title为饼状图的标题;$dataArr为需要显示的数据数组;$labelArr为对应数据的标签分类数组;$colorArr为对应数据的绘图颜色数组,这4个参数是必须的,对于不同的系统应用传递相应的参数即可。接下来的4个参数,负责设置要生成的饼状图的大小,如果不设置则使用系统默认值。程序按照床底数组数据的大小,从0度开始绘制,方向按照顺时针方向依次绘制对应数据占据的扇面大小。
<?php
//变量定义,画椭圆弧时的角度大小
define("ANGLELENGTH",3);
/**
* 绘制图片
* @param $title 3D图的标题
* @param $dataArr 显示的数据数组
* @param $labelArr 对应数据的标签分类数组
* @param $colorArr 对应绘图颜色的数组
* @param $a 画布的基准宽度
* @param $b 画布的基准高度
* @param $v 3D柱的高度
* @param $font 字体大小
* @return 绘制成功的图片访问路径
*/
function drawPieImg($title, $dataArr, $labelArr, $colorArr, $a=250, $b=120, $v=20, $font=10){
$ox = 5+$a;
$oy = 5+$b;
$fw = imagefontwidth($font);
$fh = imagefontheight($font);
$n = count($dataArr);//计算数组长度
$w = 10+$a*2;
$h = 10+$b*2+$v+($fh+2)*$n;
//创建画板
$img = imagecreate($w, $h);
//转RGB为索引色
for($i=0; $i<$n; $i++)
$colorArr[$i] = drawIndexColor($img,$colorArr[$i]);//为图像$img分配颜色
$clrbk = imagecolorallocate($img, 0xff, 0xff, 0xff);
$clrt = imagecolorallocate($img, 0x00, 0x00, 0x00);
//填充背景色
imagefill($img, 0, 0, $clrbk);
//求和
$tot = 0;
for($i=0; $i<$n; $i++)
$tot += $dataArr[$i];
//每个分类的起始角度大小
$sd = 0;
//每个分类所占据的角度大小
$ed = 0;
$ly = 10+$b*2+$v;
for($i=0; $i<$n; $i++){
$sd = $ed;
$ed += $dataArr[$i]/$tot*360;
//画3d扇面
draw3DSector($img, $ox, $oy+20, $a, $b, $v, $sd, $ed, $colorArr[$i]);
//画标签
imagefilledrectangle($img, 5, $ly, 5+$fw, $ly+$fh, $colorArr[$i]);
imagerectangle($img, 5, $ly, 5+$fw, $ly+$fh, $clrt);
//中文转码
$str = iconv("GB2312", "UTF-8", $labelArr[$i]);
imagettftext($img, $font, 0, 5+2*$fw, $ly+13, $clr


相关文档:

Linux 下php扩展 tidy 的安装 _ 参考

tidy 是一个非常帮忙的网页代码分析和纠错的工具,能够支持多种页面编码,并且支持xhtml输出。如果我们偷懒,甚至可以将整个页面缓存,最后采用tidy处理,最后输出完美的xhtml代码。
linux下安装过程如下:
首先安装tidy ,下载tidy源代码:
cvs -d:pserver: anonymous@tidy.cvs.sourceforge.net 为防备电子邮件地址收集 ......

HTTP Only cookies without PHP 5.2


HTTP Only cookies without PHP 5.2
by Matt Mecham
on September 12, 2006
For a while, Microsoft have had a flag
for cookies called ‘httponly’. This doesn’t sound particularly
exciting, but it is a vital step forward for web application security.
This flag tells Internet Expl ......

httpOnly cookie flag support in PHP 5.2

http://ilia.ws/archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html
Thanks to a patch from Scott
MacVicar that I've just applied to CVS, PHP 5.2 will have support for
httpOnly cookie flag. This neat little feature allows you to mark a
newly created cookie as HTTP only, another words inacce ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号