openflashchart 2.0 简单案例php版

前端之家收集整理的这篇文章主要介绍了openflashchart 2.0 简单案例php版前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.openflashchart是一种比较实用的图标呈现插件,而且是开源的,网址http://teethgrinder.co.uk/open-flash-chart/ 2.FlashChart类 @H_301_0@<div class="codetitle"><a style="CURSOR: pointer" data="7000" class="copybut" id="copybut7000" onclick="doCopy('code7000')"> 代码如下:

<div class="codebody" id="code7000"> @H_3010@FlashChart Class Code class FlashChart @H3010@{ @H3010@private $id; @H3010@private $height; @H3010@private $width; @H3010@private $path; @H301_0@function _construct($path="",$width=300,$height=500,$id="myChart") @H3010@{ @H301_0@global $flashchart; @H3010@$this->id=$id; @H3010@$this->height=$height; @H3010@$this->width=$width; @H3010@$this->path=$path; @H301_0@if(!$flashchart) @H3010@{ @H3010@echo '<script type="text/javascript" src="'.$path.'js/json/json2.js">'; @H3010@echo '<script type="text/javascript" src="'.$path.'js/swfobject.js">'; @H3010@echo '<script type="text/javascript" src="'.$path.'js/jquery-1.4.4.min.js">'; @H301_0@$flashchart=true; @H3010@} @H301_0@} function destruct() @H_3010@{ @H3010@unset($this->id,$this->height,$this->width,$this->path); @H3010@} @H3010@function setID($id) @H3010@{ @H3010@$this->id=$id; @H3010@} @H3010@function setChart($file,$info) @H3010@{ @H3010@$tp=new TemplateData($file); @H3010@echo '<script type="text/javascript">'; @H3010@echo "data{$this->id}=".$tp->changeInfo($info).';'; @H_301_0@echo "function ofc_getdataOf{$this->id}(){return JSON.stringify(data{$this->id});}"; @H_301_0@echo "swfobject.embedSWF('".$this->path."/open-flash-chart.swf','$this->id','$this->width','$this->height','9.0.0','expressInstall.swf',{'get-data':'ofc_getdataOf{$this->id}'} )"; @H3010@echo ''; @H3010@} @H3010@} @H3010@
@H3010@3,TemplateData类 把一个简单的图标的配置从已经写好的txt文本里取出来加载所用的类 :例如 @H301_0@<div class="codetitle"><a style="CURSOR: pointer" data="98714" class="copybut" id="copybut98714" onclick="doCopy('code98714')"> 代码如下:
<div class="codebody" id="code98714"> @H_3010@{ @H3010@"title": @H3010@{ @H3010@"text":"(title)",@H3010@"style":"{color:#FF0000;font-size:24px;}" @H3010@},@H301_0@"ylegend":{ @H3010@"text": "iWebShop",@H3010@"style": "{color: #736AFF;font-size:16px;}" @H3010@},"elements":[ @H3010@{ @H3010@"type": "line",@H3010@"colour": "#736AFF",@H301_0@"text": "注册用户量(人)",@H_3010@"width": 1,@H3010@"dot-style": { @H3010@"type":"solid-dot","colour":"#a44a80","dot-size": 3,@H301_0@"tip":"#val#人
#xlabel#" },@H3010@"on-show": {"type": "shrink-in","cascade":1,"delay":0.5},@H3010@"values" : [(numbers)] @H3010@} @H301_0@],"xaxis":{ @H3010@"labels": { @H3010@"labels":[(dates)] @H3010@} @H301_0@},"yaxis":{ @H3010@"steps": (steps),@H3010@"max": (max) @H3010@} @H3010@} @H3010@
@H301_0@这是类的内容: @H_301_0@<div class="codetitle"><a style="CURSOR: pointer" data="76688" class="copybut" id="copybut76688" onclick="doCopy('code76688')"> 代码如下:
<div class="codebody" id="code76688"> @H_3010@class TemplateData @H3010@{ @H3010@public $substitution; @H3010@private $templateFile; @H301_0@function construct($filename) @H_3010@{ @H301_0@$this->templateFile=@file_getcontents($filename) or die("not find templateFile"); @H3010@} @H301_0@function _destruct() { @H3010@unset ($this->templateFile,$this->substitution); @H3010@} @H3010@function setTemplateFile($tfile) @H3010@{ @H3010@$this->templateFile=$tfile; @H3010@} @H3010@function getTemplateFile() @H3010@{ @H3010@return $this->templateFile; @H3010@} @H3010@function replaceReal($matches) @H3010@{ @H301_0@extract($this->substitution,EXTROVERWRITE); @H3010@return isset($$matches[1])?$$matches[1]:$matches[1]; @H3010@} @H3010@function changeInfo($subs) @H3010@{ @H3010@$this->substitution=$subs; @H301_0@return preg_replacecallback("(((\w+)))",array(&$this,'replaceReal'),$this->getTemplateFile()); @H3010@} } @H3010@
@H301_0@4,调用代码 @H_301_0@<div class="codetitle"><a style="CURSOR: pointer" data="16209" class="copybut" id="copybut16209" onclick="doCopy('code16209')"> 代码如下:
<div class="codebody" id="code16209"> @H_301_0@
<div id="myChart">
<?PHP @H_301_0@include("flashchart.PHP"); @H_301_0@include("templatedata.PHP"); @H_3010@$fc=new FlashChart('chart/',"100%",320); @H3010@$infos=array( @H3010@'numbers'=>"30000,10000,5000,6000000,700",@H3010@'dates'=>"\"字符串1\",\"字符串2\",\"字符串3\",\"字符串4\",\"字符串5\"",@H3010@'steps'=>600000,@H3010@'max'=>6000000 @H3010@); @H301_0@$info=array("title"=>'用户注册统计','numbers'=>$infos['numbers'],'dates'=>$infos['dates'],'steps'=>$infos['steps'],'max'=>$infos['max']); @H_3010@$fc->setChart("chart/templatechart/user-add.txt",$info); @H3010@ @H301_0@5,还有一个处理数据的函数,把查询出来的数据集转换成ofc用的数据 <div class="codetitle"><a style="CURSOR: pointer" data="97646" class="copybut" id="copybut97646" onclick="doCopy('code97646')"> 代码如下:<div class="codebody" id="code97646"> @H_3010@/** @H3010@* @brief ofc数据处理 @H301_0@ @params 数据库查询出关于x,y轴的数据的数据集 @H_301_0@ @note 后台 @H_3010@*/ @H3010@/* @H301_0@public function initcount($rs) @H3010@{ $numbers =''; @H3010@$dates = ''; @H3010@$max = 0; @H3010@foreach($rs as $row) @H3010@{ $numbers .= $row['num'].',';//y轴数据 @H3010@$dates .='"'.$row['month'].'",';//x轴数据 @H3010@if($max<$row['num']) $max = $row['num']; @H3010@} @H3010@$steps=ceil($max/10); @H3010@$result= array( @H3010@'steps' => $steps,@H3010@'numbers' => strlen($numbers)>1 ? substr($numbers,-1):null,@H3010@'dates' => strlen($dates)>1 ? substr($dates,-1) : null,@H3010@'max' => $max+$steps @H3010@); @H3010@return $result; @H3010@} @H301_0@

openflashchart

猜你在找的PHP相关文章