柱,圆饼图处理---H_picda.php

<?php
/*************************************
*	柱,圆饼图处理---H_picda.php
*	创建人: huang_xiang
*	创建时间:2008-12-25 9:29
*	更新时间:2009-2-18 18:14
*	Email:yin273642232@163.com QQ:273642232
*************************************/
/*************************************
实例代码
	include_once("H_picda.php");													//引入文件
	$H_picda = new H_picda();														//产生对象
	
	$H_picda -> H_vor_pic();														//返回:绘制纵向柱状图
	$H_picda -> H_hor_pic();														//返回:绘制横向柱状图
	$H_picda -> H_tor_pic();														//返回:绘制饼图
	$H_picda -> H_lor_pic();														//返回:绘制纵向线性图
	$H_picda -> H_jor_pic();														//返回:绘制横向线性图
	$H_picda -> H_dispy('1');														//返回:直接输出图片 1-销毁图片 0-否 默认值1
	$H_picda -> H_store('img/myimg.jpg',1);											//返回:保存图片 1-销毁图片 0-否 默认值1
	$H_picda -> H_desty();															//返回:无 销毁图片
	$H_picda -> H_vor_pic_gif();													//返回:绘制纵向柱状图-gif动态
	$H_picda -> H_hor_pic_gif();													//返回:绘制横向柱状图-gif动态
	$H_picda -> H_tor_pic_gif();													//返回:绘制饼图-gif动态
	$H_picda -> H_lor_pic_gif();													//返回:绘制纵向线性图-gif动态
	$H_picda -> H_jor_pic_gif();													//返回:绘制横向线性图-gif动态
	$H_picda -> H_gifda('vor',0.1,3);												//返回:设置gif文件 动态(vor、hor、tor、lor、jor) 0.1-每帧间隔(单位秒) 3-最后帧与首帧的间隔(单位秒)
	$H_picda -> H_dispy_gif();														//返回:直接显示图片
	$H_picda -> H_store_gif('img/myimg.gif');										//返回:存储图片 文件名称和路径
	$H_picda = new H_picda();														//产生对象
	$H_picda -> H_ndata = array(20,12,15,15,16,12);
	$H_picda -> H_mdata = array(array('没','有'),array('4','5','是','颠','倒','是','非','0','0'),array('a','a','a','a'),array('啊','啊','啊','啊','啊'),array('d','i','s','d','f'),array());
	$H_picda -> H_liti = true;
	
	//jpg
	//$H_picda -> H_jor_pic();
	//$H_picda -> H_dispy();
	//动态gif
	
	$H_picda -> H_gifda("tor",$H_jgtm=0.1,$H_entm=3);
	$H_picda -> H_dispy_gif();
*************************************/
//Start Class
class H_picda{
	public $H_debug = false;
	public $H_desce;					//描述
	public $H_ROOT_DIR;					//文件地址路径
	public $H_img;						//图
	
	public $H_gif;						//处理gif对象
	public $H_imgda = array();			//图数据
	public $H_imgsm = 0;				//次数
	public $H_dly = array();			//延时
	public $H_lop = 0;					//循环次数
	public $H_mod = "bin";				//数据源模式
	public $H_img_gif="";				//图像字符串
	
	public $H_colwd = 20;				//色柱宽
	public $H_coljg = 20;				//色柱间间隔
	public $H_left = 20;				//左侧留空
	public $H_right = 20;				//右侧留空
	public $H_top = 20;					//上留空
	public $H_down = 10;				//下留空
	public $H_maxsz = 1;				//初始化纵轴最大数据值
	public $H_imgwd = 200;				//图像宽	
	public $H_imghg = 170;				//图像高
	public $H_ndata = array();			//参数
	public $H_mdata = array();			//参数名称(存放的是数组:eg array(array("我","爱"),array("中","华")) )
	public $H_font_file = "HEITI.ttf";	//字体
	public $H_dnum = 4;					//默认4个刻度
	public $H_liti = false;				//是否立体
	public $H_fi = 10;					//字体大小
	public $H_colcr = array(			//色柱颜色
			array(0x97, 0xbd, 0x00),
			array(0x00, 0x99, 0x00),
			array(0xcc, 0x33, 0x00),
			array(0xff, 0xcc, 0x00),
			array(0x33, 0x66, 0xcc),
			array(0x33, 0xcc, 0x33),
			array(0xff, 0x99, 0x33),
			array(0xcc, 0xcc, 0x99),
			array(0x99, 0xcc, 0x66),
			array(0x66, 0xff, 0x99));
	public $H_coltp =array(				//色柱颜色(3d 顶部)
			array(0x90, 0xa0, 0x1a),
			array(0x00, 0x7a, 0x00),
			array(0xbb, 0x00, 0x00),
			array(0xdc, 0xd0, 0x01),
			array(0x30, 0x5b, 0xc0),
			array(0x30, 0xc0, 0x29),
			array(0xf0, 0x88, 0x30),
			array(0xb0, 0xc0, 0x90),
			array(0x80, 0xba, 0x59),
			array(0x56, 0xeb, 0x80));
	public $H_colce =array(				//色柱颜色(3d 侧部)
			array(0x57, 0x6c, 0x0f),
			array(0x00, 0x6b, 0x00),
			array(0x91, 0x00, 0x00),
			array(0xd0, 0xb0, 0x0c),
			array(0x30, 0x50, 0xc0),
			array(0x26, 0xb0, 0x20),
			array(0xe0, 0x80, 0x26),
			array(0xb5, 0xb0, 0x88),
			array(0x86, 0xb2, 0x53),
			array(0x52, 0xe6, 0x82));
	public $H_mfncr;					//字体颜色
			
	public function __construct(){
		//当实例化一个对象的时候,这个对象的这个方法首先被调用
		return '';
 	}
 	public function __destruct(){
 		//当删除一个对象或对象操作终止的时候,调用该方法
 		return '';
 	}
 	public function __get($key){
 		//当试图读取一个并不存在的属性的时候被调用
  		return '['.$key.'] Variable not find';
  	}
  	public function __set($key,$val){
 		//当试图向一个并不存在的属性写入值的时候被调用
  		return '['.$key.'] Variable not find';
  	}
  	public function __call($key,$args){
  		//当试图调用一个对象并不存在的方法时,调用该方法
  		return '['.$key.'] Function not find';
	}
	public function __toString(){
		//当打印一个对象的时候被调用
		return $this -> H_desce();
  	}
  	public function __clone(){
  		//当对象被克隆时,被调用
  		return "clone";
  	}
	public function H_desce(){
		//返回描述
		$this -> H_desce .= '类名:H_picda-柱,圆饼,线性图处理;';
		$this -> H_desce .= '函数:H_vor_pic(),返回:绘制纵向柱状图,参数:无;';
		$this -> H_desce .= '函数:H_hor_pic(),返回:绘制横向柱状图,参数:无;';
		$this -> H_desce .= '函数:H_lor_pic(),返回:绘制纵向线性图,参数:无;';
		$this -> H_desce .= '函数:H_jor_pic(),返回:绘制横向线性图,参数:无;';
		$this -> H_desce .= '函数:H_tor_pic(),返回:绘制饼图,参数:无;';
		$this -> H_desce .= '函数:H_dispy($H_dest=1),返回:直接输出图片,参数:$H_dest-是否销毁图片;';
		$this -> H_desce .= '函数:H_store($H_urlnm,$H_dest=1),返回:保存图片,参数:$H_urlnm-保存图片路径及文件名.$H_dest-是否销毁图片;';
		$this -> H_desce .= '函数:H_desty(),返回:无,参数:无;';
		$this -> H_desce .= '函数:H_vor_pic_gif(),返回:绘制纵向柱状图-gif动态,参数:无;';
		$this -> H_desce .= '函数:H_hor_pic_gif(),返回:绘制横向柱状图-gif动态,参数:无;';
		$this -> H_desce .= '函数:H_lor_pic_gif(),返回:绘制纵向线性图-gif动态,参数:无;';
		$this -> H_desce .= '函数:H_jor_pic_gif(),返回:绘制横向线性图-gif动态,参数:无;';
		$this -> H_desce .= '函数:H_tor_pic_gif(),返回:绘制饼图-gif动态,参数:无;';
		$this -> H_desce .= '函数:H_gifda($H_type="vor",$H_jgtm=1,$H_entm=3),返回:无 设置gif文件,参数:$H_type-动态(vor、hor、tor、lor、jor).$H_jgtm-每帧间隔(单位秒).$H_entm-最后帧与首帧的间隔(单位秒);';
		$this -> H_desce .= '函数:H_dispy_gif(),返回:无 显示图片,参数:无;';
		$this -> H_desce .= '函数:H_store_gif($H_urlnm),返回:无 存储图片,参数:$H_urlnm-文件名称和路径;';
		return $this -> H_desce;
	}
	public function H_vor_pic(){
		//生成柱形图(纵向)	
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left += 10*(strlen(strval($this -> H_maxsz))-2);
		//计算图像宽度
		$this -> H_imgwd = $this -> H_left+$this -> H_right+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if($this -> H_mdata[$i] == "") $this -> H_mdata[$i] = array("默","认","名","称");
			//else $this -> H_mdata[$i] = explode(" ",$this -> H_mdata[$i]);
		}
		//存储色柱高度的数组
		$H_colhg = array();	//柱子高度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);		
		//纵轴刻度,纵轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img, $this -> H_left, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum, $this -> H_left+6,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum,$H_axecr);
			imagestring($this -> H_img, 3, $this -> H_left/$this -> H_dnum, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum-5,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colhg, round(($this -> H_imghg-$this -> H_top-$this -> H_down)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagefilledrectangle($this -> H_img,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],
						$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1 ,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			if($this -> H_liti){
				imagefilledpolygon($this -> H_img,array($this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i]),4,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]));
				imagefilledpolygon($this -> H_img,array($this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-5,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i]),4,imagecolorallocate($this -> H_img,$this ->H_coltp[$H_colri][0],$this ->H_coltp[$H_colri][1],$this ->H_coltp[$H_colri][2]));
			}
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
		//标注数据柱上方数据值
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagestring($this -> H_img,1,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-10,$this -> H_ndata[$i],$this -> H_mfncr);
			for($ii=0;$ii < count($this -> H_mdata[$i]);$ii++){
				ImageTTFText($this -> H_img,$this-> H_fi,0,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+2,$this -> H_imghg-$this -> H_down-$ii*($this-> H_fi+5)-2,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i][count($this -> H_mdata[$i])-$ii-1]));
			}
		}
	}
	public function H_hor_pic(){
		//生成柱形图(横向)
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left = 10;				//左侧留空
		$this -> H_down = 20;				//下留空
		//计算图像宽度
		$this -> H_imghg = $this -> H_down+$this -> H_top+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(is_array($this -> H_mdata[$i])) $this -> H_mdata[$i] = implode("",$this -> H_mdata[$i]);
			else $this -> H_mdata[$i] = $this -> H_mdata[$i] == "" ? "默认名称" : $this -> H_mdata[$i];
		}
		$this -> H_imgwd += $this -> H_imgwd+10*(strlen(strval($this -> H_maxsz))-2);
		//存储色柱高度的数组
		$H_colwd = array();	//柱子宽度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);
		//横轴刻度,横轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img,$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum,$this -> H_imghg-$this -> H_down,
							$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum, $this -> H_imghg-$this -> H_down-6, $H_axecr);
			imagestring($this -> H_img, 3,$this -> H_left+(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum-5),$this -> H_imghg-$this -> H_down+2,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colwd, round(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagefilledrectangle($this -> H_img,1+$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg),
						$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			if($this -> H_liti){
				imagefilledpolygon($this -> H_img,array(1+$this -> H_left+5,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-$this -> H_colwd,
							1+$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)),4,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]));
				imagefilledpolygon($this -> H_img,array(1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5+$this -> H_colwd,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-$this -> H_colwd),4,imagecolorallocate($this -> H_img,$this ->H_coltp[$H_colri][0],$this ->H_coltp[$H_colri][1],$this ->H_coltp[$H_colri][2]));
			}
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
		//标注数据柱上方数据值
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagestring($this -> H_img,1,$this -> H_left+$H_colwd[$i]+2,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3),$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3)-8,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i]));
		}
	}
	public function H_tor_pic(){
		//生成圆饼图
		//得到最大值
		$H_size = 10;
		$H_myjg = 5;
		$H_ii = 0;
		$H_temp = 0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: 不是数字!");
			if($this -> H_ndata[$i] > $H_temp){
				$H_temp = $this -> H_ndata[$i];
				$H_ii = $i;
			}
			$this -> H_maxsz += $this -> H_ndata[$i];
		}
		//再次遍历,计算色块角度并存入数组
		$H_poivw = array();
		$H_totol = 0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			$H_temp = round(360*$this -> H_ndata[$i]/$this -> H_maxsz);
			array_push($H_poivw,$H_temp);
			$H_totol += $H_temp;
		}
		if($H_totol != 360) $H_poivw[$H_ii] += (360-$H_totol);
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg+(count($this -> H_ndata)/2*($H_size+$H_myjg)));
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		$H_wdhg = 20;
		$H_torwd = $this -> H_imgwd -$H_wdhg;
		$H_torhg = $this -> H_imghg -$H_wdhg;
		if($this -> H_liti){
			for ($temp = $H_torhg/2+5; $temp > $H_torhg/2-5; $temp--) {
				$H_start=0;
				$H_end=0;
				$H_colri=0;
				for ($i = 0; $i < count($this -> H_ndata); $i++){
					$H_end=$H_start+$H_poivw[$i];
					imagefilledarc($this -> H_img,$this -> H_imgwd/2,$temp,$H_torwd,$H_torhg-20,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]),IMG_ARC_PIE);
					$H_start+=$H_poivw[$i];
					$H_end+=$H_poivw[$i];
					if($H_colri==count($this -> H_colcr)-1){
						$H_colri=0;
					}else{
						$H_colri++;
					}
				}
			}
			$H_colri=0;
			for($i = 0; $i < count($this -> H_ndata); $i++) {
				$H_end=$H_start+$H_poivw[$i];
				imagefilledarc($this -> H_img,$this -> H_imgwd/2,$temp,$H_torwd,$H_torhg-20,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
				imagestring($this -> H_img,1,$H_start,$H_end,$this -> H_ndata[$i],$H_axecr);
				$H_start+=$H_poivw[$i];
				$H_end+=$H_poivw[$i];
				if($H_colri==count($this -> H_colcr)-1){
					$H_colri=0;
				}else{
					$H_colri++;
				}
			}
		}else{
			$H_colri=0;
			$H_start = 0;
			$H_end = 0;
			for($i=0;$i < count($this -> H_ndata);$i++){
				//绘制扇区
				$H_end = $H_start+$H_poivw[$i];
				imagefilledarc($this -> H_img,$this -> H_imgwd/2,$this -> H_imghg/2,$H_torwd,$H_torhg,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
				$H_start = $H_end;
				if($H_colri==count($this -> H_colcr)-1){
					$H_colri=0;
				}else{
					$H_colri++;
				}
			}
		}
		//标注数据柱上方数据值
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			$H_px = $i%2==1 ? $this -> H_imgwd/2 : 10;
			$H_py = $i%2==0 ? $H_torhg+15+$i/2*($H_size+$H_myjg):$H_py;
			$H_qx = $H_px+$H_size;
			$H_qy = $H_py+$H_size;
			imagefilledrectangle($this -> H_img,$H_px,$H_py,$H_qx,$H_qy,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			imagestring($this -> H_img,1,$H_px+$H_size+$H_myjg,$H_py,$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$H_px+$H_size+$H_myjg+20,$H_qy,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",implode("",$this -> H_mdata[$i])));
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
	}
	public function H_lor_pic(){
		//生成线性图(纵向)	
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left += 10*(strlen(strval($this -> H_maxsz))-2);
		//计算图像宽度
		$this -> H_imgwd = $this -> H_left+$this -> H_right+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if($this -> H_mdata[$i] == "") $this -> H_mdata[$i] = array("默","认","名","称");
			//else $this -> H_mdata[$i] = explode(" ",$this -> H_mdata[$i]);
		}
		//存储色柱高度的数组
		$H_colhg = array();	//柱子高度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);		
		$H_endpx = $this -> H_left;
		$H_stapy = $this -> H_imghg-$this -> H_down;
		//纵轴刻度,纵轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img, $this -> H_left, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum, $this -> H_left+6,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum,$H_axecr);
			imagestring($this -> H_img, 3, $this -> H_left/$this -> H_dnum, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum-5,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个点的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colhg, round(($this -> H_imghg-$this -> H_top-$this -> H_down)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//标注数据柱上方数据值
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagestring($this -> H_img,1,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-10,$this -> H_ndata[$i],$this -> H_mfncr);
			for($ii=0;$ii < count($this -> H_mdata[$i]);$ii++){
				ImageTTFText($this -> H_img,$this-> H_fi,0,$this -> H_left+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,$this -> H_imghg-$this -> H_down-$ii*($this-> H_fi+5)-2,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i][count($this -> H_mdata[$i])-$ii-1]));
			}
		}
		//画数据点
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagefilledarc($this -> H_img,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],5,5,0,360,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
			imageline($this -> H_img,$H_endpx,$H_stapy,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			$H_endpx = $this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg);
			$H_stapy = $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i];
			//无立体效果
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
		
	}
	public function H_jor_pic(){
		//生成线形图(横向)
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left = 10;				//左侧留空
		$this -> H_down = 20;				//下留空
		//计算图像宽度
		$this -> H_imghg = $this -> H_down+$this -> H_top+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(is_array($this -> H_mdata[$i])) $this -> H_mdata[$i] = implode("",$this -> H_mdata[$i]);
			else $this -> H_mdata[$i] = $this -> H_mdata[$i] == "" ? "默认名称" : $this -> H_mdata[$i];
		}
		$this -> H_imgwd += $this -> H_imgwd+10*(strlen(strval($this -> H_maxsz))-2);
		//存储色柱高度的数组
		$H_colwd = array();	//柱子宽度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x00);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);
		$H_endpx = $this -> H_left;
		$H_stapy = $this -> H_top/2;
		//横轴刻度,横轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img,$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum,$this -> H_imghg-$this -> H_down,
							$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum, $this -> H_imghg-$this -> H_down-6, $H_axecr);
			imagestring($this -> H_img, 3,$this -> H_left+(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum-5),$this -> H_imghg-$this -> H_down+2,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colwd, round(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//标注数据柱上方数据值
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagestring($this -> H_img,1,$this -> H_left+$H_colwd[$i]+2,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3),$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3)+$this -> H_coljg,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i]));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			imagefilledarc($this -> H_img,$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,5,5,0,360,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
			imageline($this -> H_img,$H_endpx,$H_stapy,$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			$H_endpx = $this -> H_left+$H_colwd[$i];
			$H_stapy = $this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg;
			//无立体效果
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
	}
	public function H_dispy($H_type="png",$H_dest=1){
		//显示图片
		header('Content-type: image/'.$H_type);
		switch($H_type){
			case "jpeg" : {
				imagejpeg($this -> H_img);
				break;	
			}
			case "png" : {
				imagepng($this -> H_img);
				break;	
			}
			case "gif" : {
				imagegif($this -> H_img);
				break;
			}
			default :
			imagepng($this -> H_img);
		}
		if($H_dest == 1) imagedestroy($this -> H_img);
	}
	public function H_store($H_urlnm="temp",$H_type="png",$H_dest=1){
		//存储图片
		switch($H_type){
			case "jpeg" : {
				imagejpeg($this -> H_img,$H_urlnm.".jpg");
				break;	
			}
			case "png" : {
				imagepng($this -> H_img,$H_urlnm.".png");
				break;	
			}
			case "gif" : {
				imagegif($this -> H_img,$H_urlnm.".gif");
				break;	
			}
			default :
			imagepng($this -> H_img,$H_urlnm.".png");
		}
		if($H_dest == 1) imagedestroy($this -> H_img);	
	}
	public function H_desty(){
		//销毁图片
		if($this -> H_img) imagedestroy($this -> H_img);	
	}
	public function H_vor_pic_gif($H_gifi){
		//生成柱形图(纵向)  gif动态
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		if($this -> H_imgsm < 1) $this -> H_left += 10*(strlen(strval($this -> H_maxsz))-2);
		//计算图像宽度
		$this -> H_imgwd = $this -> H_left+$this -> H_right+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if($this -> H_mdata[$i] == "") $this -> H_mdata[$i] = array("默","认","名","称");
			//else $this -> H_mdata[$i] = explode(" ",$this -> H_mdata[$i]);
		}
		//存储色柱高度的数组
		$H_colhg = array();	//柱子高度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);		
		//纵轴刻度,纵轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img, $this -> H_left, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum, $this -> H_left+6,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum,$H_axecr);
			imagestring($this -> H_img, 3, $this -> H_left/$this -> H_dnum, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum-5,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colhg, round(($this -> H_imghg-$this -> H_top-$this -> H_down)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < $H_gifi+1;$i++){
			imagefilledrectangle($this -> H_img,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],
						$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1 ,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			if($this -> H_liti){
				imagefilledpolygon($this -> H_img,array($this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i]),4,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]));
				imagefilledpolygon($this -> H_img,array($this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-5,
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+5,($this -> H_imghg-$this -> H_down)-1-5-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i],
							$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),($this -> H_imghg-$this -> H_down)-1-$H_colhg[$i]),4,imagecolorallocate($this -> H_img,$this ->H_coltp[$H_colri][0],$this ->H_coltp[$H_colri][1],$this ->H_coltp[$H_colri][2]));
			}
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
		//标注数据柱上方数据值
		for($i=0;$i < $H_gifi+1;$i++){
			imagestring($this -> H_img,1,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-10,$this -> H_ndata[$i],$this -> H_mfncr);
			for($ii=0;$ii < count($this -> H_mdata[$i]);$ii++){
				ImageTTFText($this -> H_img,$this-> H_fi,0,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd+2,$this -> H_imghg-$this -> H_down-$ii*($this-> H_fi+5)-2,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i][count($this -> H_mdata[$i])-$ii-1]));
			}
		}
	}
	public function H_hor_pic_gif($H_gifi){
		//生成柱形图(横向) gif动态
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left = 10;				//左侧留空
		$this -> H_down = 20;				//下留空
		//计算图像宽度
		$this -> H_imghg = $this -> H_down+$this -> H_top+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(is_array($this -> H_mdata[$i])) $this -> H_mdata[$i] = implode("",$this -> H_mdata[$i]);
			else $this -> H_mdata[$i] = $this -> H_mdata[$i] == "" ? "默认名称" : $this -> H_mdata[$i];
		}
		if($this -> H_imgsm < 1) $this -> H_imgwd += $this -> H_imgwd+10*(strlen(strval($this -> H_maxsz))-2);
		//存储色柱高度的数组
		$H_colwd = array();	//柱子宽度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);
		//横轴刻度,横轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img,$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum,$this -> H_imghg-$this -> H_down,
							$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum, $this -> H_imghg-$this -> H_down-6, $H_axecr);
			imagestring($this -> H_img, 3,$this -> H_left+(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum-5),$this -> H_imghg-$this -> H_down+2,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colwd, round(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < $H_gifi+1;$i++){
			imagefilledrectangle($this -> H_img,1+$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg),
						$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			if($this -> H_liti){
				imagefilledpolygon($this -> H_img,array(1+$this -> H_left+5,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-$this -> H_colwd,
							1+$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)),4,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]));
				imagefilledpolygon($this -> H_img,array(1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5,
							1+$this -> H_left+5+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)-5+$this -> H_colwd,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,
							$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-$this -> H_colwd),4,imagecolorallocate($this -> H_img,$this ->H_coltp[$H_colri][0],$this ->H_coltp[$H_colri][1],$this ->H_coltp[$H_colri][2]));
			}
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
		//标注数据柱上方数据值
		for($i=0;$i < $H_gifi+1;$i++){
			imagestring($this -> H_img,1,$this -> H_left+$H_colwd[$i]+2,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3),$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3)-8,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i]));
		}
	}
	public function H_tor_pic_gif($H_gifi){
		//生成圆饼图 gif动态
		//得到最大值
		$H_size = 10;
		$H_myjg = 5;
		$H_ii = 0;
		$H_temp = 0;
		$this -> H_maxsz = 0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number");
			if($this -> H_ndata[$i] > $H_temp){
				$H_temp = $this -> H_ndata[$i];
				$H_ii = $i;
			}
			$this -> H_maxsz += $this -> H_ndata[$i];
		}
		//再次遍历,计算色块角度并存入数组
		$H_poivw = array();
		$H_totol = 0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			$H_temp = round(360*$this -> H_ndata[$i]/$this -> H_maxsz);
			array_push($H_poivw,$H_temp);
			$H_totol += $H_temp;
		}
		if($H_totol != 360) $H_poivw[$H_ii] += (360-$H_totol);
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg+(count($this -> H_ndata)/2*($H_size+$H_myjg)));
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		$H_wdhg = 20;
		$H_torwd = $this -> H_imgwd -$H_wdhg;
		$H_torhg = $this -> H_imghg -$H_wdhg;
		if($this -> H_liti){
			for($temp = $H_torhg/2+5; $temp > $H_torhg/2-5; $temp--) {
				$H_start=0;
				$H_end=0;
				$H_colri=0;
				for ($i = 0; $i < $H_gifi+1; $i++){
					$H_end=$H_start+$H_poivw[$i];
					imagefilledarc($this -> H_img,$this -> H_imgwd/2,$temp,$H_torwd,$H_torhg-20,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colce[$H_colri][0],$this ->H_colce[$H_colri][1],$this ->H_colce[$H_colri][2]),IMG_ARC_PIE);
					$H_start+=$H_poivw[$i];
					$H_end+=$H_poivw[$i];
					if($H_colri==count($this -> H_colcr)-1){
						$H_colri=0;
					}else{
						$H_colri++;
					}
				}
			}
			$H_start=0;
			$H_colri=0;
			for($i = 0; $i < $H_gifi+1; $i++) {
				$H_end=$H_start+$H_poivw[$i];
				imagefilledarc($this -> H_img,$this -> H_imgwd/2,$temp,$H_torwd,$H_torhg-20,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
				$H_start+=$H_poivw[$i];
				$H_end+=$H_poivw[$i];
				if($H_colri==count($this -> H_colcr)-1){
					$H_colri=0;
				}else{
					$H_colri++;
				}
			}			
		}else{
			$H_colri=0;
			$H_start = 0;
			$H_end = 0;
			for($i=0;$i < $H_gifi+1;$i++){
				//绘制扇区
				$H_end = $H_start+$H_poivw[$i];
				imagefilledarc($this -> H_img,$this -> H_imgwd/2,$this -> H_imghg/2,$H_torwd,$H_torhg,$H_start,$H_end,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
				$H_start = $H_end;
				if($H_colri==count($this -> H_colcr)-1){
					$H_colri=0;
				}else{
					$H_colri++;
				}
			}
		}
		//标注数据柱上方数据值
		$H_colri=0;
		for($i=0;$i < count($this -> H_ndata);$i++){
			$H_px = $i%2==1 ? $this -> H_imgwd/2 : 10;
			$H_py = $i%2==0 ? $H_torhg+15+$i/2*($H_size+$H_myjg):$H_py;
			$H_qx = $H_px+$H_size;
			$H_qy = $H_py+$H_size;
			imagefilledrectangle($this -> H_img,$H_px,$H_py,$H_qx,$H_qy,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			imagestring($this -> H_img,1,$H_px+$H_size+$H_myjg,$H_py,$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$H_px+$H_size+$H_myjg+20,$H_qy,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",implode("",$this -> H_mdata[$i])));
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
	}
	public function H_lor_pic_gif($H_gifi){
		//生成线性图(纵向)  gif动态
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		if($this -> H_imgsm < 1) $this -> H_left += 10*(strlen(strval($this -> H_maxsz))-2);
		//计算图像宽度
		$this -> H_imgwd = $this -> H_left+$this -> H_right+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if($this -> H_mdata[$i] == "") $this -> H_mdata[$i] = array("默","认","名","称");
			//else $this -> H_mdata[$i] = explode(" ",$this -> H_mdata[$i]);
		}
		//存储色柱高度的数组
		$H_colhg = array();	//柱子高度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);		
		$H_endpx = $this -> H_left;
		$H_stapy = $this -> H_imghg-$this -> H_down;
		//纵轴刻度,纵轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img, $this -> H_left, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum, $this -> H_left+6,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum,$H_axecr);
			imagestring($this -> H_img, 3, $this -> H_left/$this -> H_dnum, $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)*($this -> H_dnum-$i)/$this -> H_dnum-5,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colhg, round(($this -> H_imghg-$this -> H_top-$this -> H_down)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//标注数据柱上方数据值
		for($i=0;$i < $H_gifi+1;$i++){
			imagestring($this -> H_img,1,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg)+5,$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i]-10,$this -> H_ndata[$i],$this -> H_mfncr);
			for($ii=0;$ii < count($this -> H_mdata[$i]);$ii++){
				ImageTTFText($this -> H_img,$this-> H_fi,0,$this -> H_left+$i*($this -> H_colwd+$this -> H_coljg)+$this -> H_colwd,$this -> H_imghg-$this -> H_down-$ii*($this-> H_fi+5)-2,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i][count($this -> H_mdata[$i])-$ii-1]));
			}
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < $H_gifi+1;$i++){
			imagefilledarc($this -> H_img,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],5,5,0,360,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
			imageline($this -> H_img,$H_endpx,$H_stapy,$this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg),$this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i],imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			$H_endpx = $this -> H_left+$this -> H_coljg+$i*($this -> H_colwd+$this -> H_coljg);
			$H_stapy = $this -> H_top+($this -> H_imghg-$this -> H_top-$this -> H_down)-$H_colhg[$i];
			//无立体效果
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
	}
	public function H_jor_pic_gif($H_gifi){
		//生成线形图(横向) gif动态
		//得到最大值
		for($i = 0; $i < count($this -> H_ndata); $i++){
			if(!is_numeric($this -> H_ndata[$i])) die("ERROR: not number!");
			$this -> H_maxsz = $this -> H_ndata[$i] > $this -> H_maxsz ? $this -> H_ndata[$i] : $this -> H_maxsz;
		}
		$this -> H_left = 10;				//左侧留空
		$this -> H_down = 20;				//下留空
		//计算图像宽度
		$this -> H_imghg = $this -> H_down+$this -> H_top+$this -> H_coljg+count($this -> H_ndata)*($this -> H_colwd+$this -> H_coljg);
		for($i=0;$i < count($this -> H_ndata);$i++){
			if(is_array($this -> H_mdata[$i])) $this -> H_mdata[$i] = implode("",$this -> H_mdata[$i]);
			else $this -> H_mdata[$i] = $this -> H_mdata[$i] == "" ? "默认名称" : $this -> H_mdata[$i];
		}
		if($this -> H_imgsm < 1) $this -> H_imgwd += $this -> H_imgwd+10*(strlen(strval($this -> H_maxsz))-2);
		//存储色柱高度的数组
		$H_colwd = array();	//柱子宽度
		$this -> H_img = imagecreate($this -> H_imgwd,$this -> H_imghg);
		//图像背景色
		$H_white = imagecolorallocate($this -> H_img, 0xEE, 0xEE, 0xEE);
		//坐标轴颜色
		$H_axecr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//字体颜色
		$this -> H_mfncr = imagecolorallocate($this -> H_img, 0x00, 0x00, 0x01);
		//横轴
		imageline($this -> H_img,$this -> H_left,$this -> H_imghg-$this -> H_down,$this -> H_imgwd-$this -> H_right/2,$this -> H_imghg-$this -> H_down,$H_axecr);
		//纵轴
		imageline($this -> H_img,$this -> H_left,$this -> H_top/2, $this -> H_left,$this -> H_imghg-$this -> H_down,$H_axecr);
		$H_endpx = $this -> H_left;
		$H_stapy = $this -> H_top/2;
		//横轴刻度,横轴上共标注N个点(包含0)
		for($i=$this -> H_dnum;$i > -1;$i--){
			imageline($this -> H_img,$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum,$this -> H_imghg-$this -> H_down,
							$this -> H_left+($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum, $this -> H_imghg-$this -> H_down-6, $H_axecr);
			imagestring($this -> H_img, 3,$this -> H_left+(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$i/$this -> H_dnum-5),$this -> H_imghg-$this -> H_down+2,round($this -> H_maxsz*$i/$this -> H_dnum),$H_axecr);
		}
		//得到每个柱的高度
		for($i=0;$i < count($this -> H_ndata);$i++){
			array_push ($H_colwd, round(($this -> H_imgwd-$this -> H_left-$this -> H_right)*$this -> H_ndata[$i]/$this -> H_maxsz));
		}
		//标注数据柱上方数据值
		for($i=0;$i < $H_gifi+1;$i++){
			imagestring($this -> H_img,1,$this -> H_left+$H_colwd[$i]+2,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3),$this -> H_ndata[$i],$this -> H_mfncr);
			ImageTTFText($this -> H_img,$this -> H_fi,0,$this -> H_left,$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg-($this -> H_colwd*2/3)+$this -> H_coljg,$this -> H_mfncr,$this -> H_ROOT_DIR."ZTK/".$this -> H_font_file,iconv("GB2312","UTF-8//IGNORE",$this -> H_mdata[$i]));
		}
		//画数据柱
		$H_colri=0;
		for($i=0;$i < $H_gifi+1;$i++){
			imagefilledarc($this -> H_img,$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,5,5,0,360,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]),IMG_ARC_PIE);
			imageline($this -> H_img,$H_endpx,$H_stapy,$this -> H_left+$H_colwd[$i],$this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg,imagecolorallocate($this -> H_img,$this ->H_colcr[$H_colri][0],$this ->H_colcr[$H_colri][1],$this ->H_colcr[$H_colri][2]));
			$H_endpx = $this -> H_left+$H_colwd[$i];
			$H_stapy = $this -> H_imghg-$this -> H_down-(count($this -> H_ndata)-$i)*($this -> H_colwd+$this -> H_coljg)+$this -> H_coljg;
			//无立体效果
			if($H_colri==count($this -> H_colcr)-1){
				$H_colri=0;
			}else{
				$H_colri++;
			}
		}
	}
	public function H_gifda($H_type="vor",$H_jgtm=0.1,$H_entm=1){
		//显示图片(gif 动态)
		ob_start();
		$H_colri = 0;
		while($H_gifi < count($this -> H_ndata)){
			switch($H_type){
				case "vor" : {
					$this -> H_vor_pic_gif($H_gifi);
					break;	
				}
				case "hor" : {
					$this -> H_hor_pic_gif($H_gifi);
					break;	
				}
				case "tor" : {
					$this -> H_tor_pic_gif($H_gifi);
					break;	
				}
				case "lor" : {
					$this -> H_lor_pic_gif($H_gifi);
					break;	
				}
				case "jor" : {
					$this -> H_jor_pic_gif($H_gifi);
					break;	
				}
				default : 
					die("Please input the right parameter!");
				exit;
			}			
			imagegif($this -> H_img);
	        imagedestroy($this -> H_img);
	        $this -> H_imgda[] =  ob_get_contents();
			ob_clean();
			if($H_gifi == count($this -> H_ndata)-1) $this -> H_dly[] = $H_entm*100;	//循环的间隔时间(1000/100=10 s) -1:结束
			else $this -> H_dly[] = $H_jgtm*100;	//每帧的间隔时间 十分之一秒 -1:结束
			$H_gifi++;
			++$this -> H_imgsm;
		}
		//include_once($this -> H_ROOT_DIR."H_gif.php");
		//数据源 延时 循环次数 透明度 r g b "bin/url"
		$this -> H_gif = new H_gif();
		$this -> H_gif -> H_set_gif($this -> H_imgda,$this -> H_dly,$this -> H_lop,2,$H_r=0,$H_g=0,$H_b=0,$this -> H_mod);
		$this -> H_img_gif = $this -> H_gif -> GetAnimation();
	}
	public function H_dispy_gif(){
		//输出
		Header('Content-type:image/gif');
		echo $this -> H_img_gif;
	}
	public function H_store_gif($H_urlnm="temp"){
		//输出文件
		$H_urlnm .=".gif";
		if(@file_exists($H_urlnm)){
			die("该文件已经存在!");	
		}if(!$H_tpstr = @fopen($H_urlnm,"w")){
			die("该文件或路径有没有足够的权限!");	
		}else{
			fwrite($H_tpstr,$this -> H_img_gif);
			fclose($H_tpstr);
			echo "OK";
		}
	}
}//End Class
?>

 

posted @ 2012-01-17 15:31  祥辉  阅读(259)  评论(0编辑  收藏  举报