`

ZXCHART的PHP 函数封装

阅读更多

function zxchart($fdata,$style=null,$path=null){
	if (empty($fdata)) {
		echo "未指定数据文件" ;return ;
	}
	
	$chart_baseurl = empty($path)? FLEA::getAppInf('public_url') . '/chart':$path;
	$fprogram = "{$chart_baseurl}/zxchart.swf" ;	
	if (!empty($style) && vefityResExist(FLEA::getAppInf('public_path'),"/chart/style/{$style}.stl")){
		$fstyle = "{$chart_baseurl}/style/{$style}.stl" ;		
	}else 
		$fstyle = "{$chart_baseurl}/style/pie2.stl" ;
		
	$_reallink = sprintf("%s?datafile=%s&stylefile=%s",$fprogram,$fdata,$fstyle);
	
	$_fmt = '
<object classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="300">
<param name=movie value="%s">
<param name=quality value=high>
<embed src ="%s" quality=high type="application/x-shockwave-flash" width="400" height="300">
</embed>
</object>	
	' ;	
	echo sprintf($_fmt,$_reallink,$_reallink);
}

function UTF82GBK($text=null){
	if (!empty($text) && function_exists('iconv')){
		return iconv("UTF-8", "GBK", $text);
	}
	return $text ;
}

function zxchart_data($cols_headers,$rows_data,$toptext='Top',$btmtext='Bottom',
	$lfttext='Left',$rightext='Right')
{
	define('ZXCHART_DATA_SL','\n');//定义换行符,必须是windows风格的
	echo UTF82GBK(sprintf('&tTText=%s&tBText=%s&tLText=%s&tRText=%s',$toptext,$btmtext,
		$lfttext,$rightext));
		
	$cols_headers = (empty($cols_headers))?array('','J','Q'):$cols_headers;	
	$cols_headers = implode(";", $cols_headers);
	
	echo UTF82GBK("&title={$cols_headers};\n") ;
	
	if (!is_array($rows_data))
		return ;
	$i=1;	
	while(!empty($rows_data)){
		$row = array_shift($rows_data);
		if (!empty($row)&&is_array($row)){
			$s = "&data{$i}=" . implode(";", $row) . ";";
			echo UTF82GBK($s).ZXCHART_DATA_SL;	
		}
		$i++;		
	}
}
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics