日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php flash chart,openflashchart 2.0 简单案例php版

發布時間:2024/4/13 php 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php flash chart,openflashchart 2.0 简单案例php版 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.openflashchart是一種比較實用的圖標呈現插件,而且是開源的,網址http://teethgrinder.co.uk/open-flash-chart/

2.FlashChart類

FlashChart Class Code

class FlashChart

{

private $id;

private $height;

private $width;

private $path;

function __construct($path="",$width=300,$height=500,$id="myChart")

{

global $flash_chart;

$this->id=$id;

$this->height=$height;

$this->width=$width;

$this->path=$path;

if(!$flash_chart)

{

echo '';

echo '';

echo '';

$flash_chart=true;

}

}

function __destruct()

{

unset($this->id,$this->height,$this->width,$this->path);

}

function setID($id)

{

$this->id=$id;

}

function setChart($file,$info)

{

$tp=new TemplateData($file);

echo '

echo "data_{$this->id}=".$tp->changeInfo($info).';';

echo "function ofc_get_dataOf{$this->id}(){return JSON.stringify(data_{$this->id});}";

echo "swfobject.embedSWF('".$this->path."/open-flash-chart.swf', '$this->id', '$this->width','$this->height','9.0.0','expressInstall.swf',{'get-data':'ofc_get_dataOf{$this->id}'} )";

echo '';

}

}

3,TemplateData類

把一個簡單的圖標的配置從已經寫好的txt文本里取出來加載所用的類 :例如

{

"title":

{

"text":"(title)",

"style":"{color:#FF0000;font-size:24px;}"

},

"y_legend":{

"text": "iWebShop",

"style": "{color: #736AFF;font-size:16px;}"

},

"elements":[

{

"type": "line",

"colour": "#736AFF",

"text": "注冊用戶量(人)",

"width": 1,

"dot-style": {

"type":"solid-dot", "colour":"#a44a80", "dot-size": 3,

"tip":"#val#人
#x_label#" },

"on-show": {"type": "shrink-in", "cascade":1, "delay":0.5},

"values" : [(numbers)]

}

],

"x_axis":{

"labels": {

"labels":[(dates)]

}

},

"y_axis":{

"steps": (steps),

"max": (max)

}

}

這是類的內容:

class TemplateData

{

public $substitution;

private $templateFile;

function __construct($filename)

{

$this->templateFile=@file_get_contents($filename) or die("not find templateFile");

}

function __destruct() {

unset ($this->templateFile,$this->substitution);

}

function setTemplateFile($tfile)

{

$this->templateFile=$tfile;

}

function getTemplateFile()

{

return $this->templateFile;

}

function replaceReal($matches)

{

extract($this->substitution, EXTR_OVERWRITE);

return isset($$matches[1])?$$matches[1]:$matches[1];

}

function changeInfo($subs)

{

$this->substitution=$subs;

return preg_replace_callback("(\((\w+)\))",array(&$this, 'replaceReal'),$this->getTemplateFile());

}

}

4,調用的代碼

include("flashchart.php");

include("templatedata.php");

$fc=new FlashChart('chart/',"100%",320);

$infos=array(

'numbers'=>"30000,10000,5000,6000000,700",

'dates'=>"\"字符串1\",\"字符串2\",\"字符串3\",\"字符串4\",\"字符串5\"",

'steps'=>600000,

'max'=>6000000

);

$info=array("title"=>'用戶注冊統計','numbers'=>$infos['numbers'],'dates'=>$infos['dates'],'steps'=>$infos['steps'],'max'=>$infos['max']);

$fc->setChart("chart/templatechart/user-add.txt",$info);

5,還有一個處理數據的函數,把查詢出來的數據集轉換成ofc用的數據

/**

* @brief ofc數據處理

* @params 數據庫查詢出關于x,y軸的數據的數據集

* @note 后臺

*/

/*

public function init_count($rs)

{

$numbers ='';

$dates = '';

$max = 0;

foreach($rs as $row)

{

$numbers .= $row['num'].',';//y軸數據

$dates .='"'.$row['month'].'",';//x軸數據

if($max

}

$steps=ceil($max/10);

$result= array(

'steps' => $steps,

'numbers' => strlen($numbers)>1 ? substr($numbers,0,-1):null,

'dates' => strlen($dates)>1 ? substr($dates,0,-1) : null,

'max' => $max+$steps

);

return $result;

}

總結

以上是生活随笔為你收集整理的php flash chart,openflashchart 2.0 简单案例php版的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。