Open Flash Chart 实时加载
//测试实时在线
public function shishi(){
$values = "";
for($i = 1; $i <= 9; $i ++) {
$values .= rand(1,10).",";
}
$file = fopen(SITE_PATH."/test.txt","w");
fwrite($file, $values."AAA");
fclose($file);
//$values="2,4,5,6,7,8,9,9,4";
$this->assign('values',$values);
$this->display();
}
public function ajax_shishi(){
$values = "";
for($i = 1; $i <= 12; $i ++) {
$values .= rand(1,12).",";
}
$file = fopen(SITE_PATH."/test.txt","w");
fwrite($file, $values."AAA");
fclose($file);
//$values="2,4,5,6,7,8,9,9,4";
$this->assign('values',$values);
$this->display();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript"> function onrollout() { tmp = findSWF("ofc"); x = tmp.rollout(); } function onrollout2() { tmp = findSWF("ofc"); x = tmp.rollout(); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } </script> </head> <body> <script type="text/javascript" src="{$site_url}/fchart/swfobject.js"></script> <div id="my_chart" style="padding: 0px; margin:10px; border: 1px solid lightblue; width: 650px; height: 600px;"></div> <script type="text/javascript"> function test(){ var site_url = '{$site_url}'; var so = new SWFObject(site_url+"/fchart/open-flash-chart.swf", "ofc", "650", "400", "9", "#FFFFFF"); so.addVariable("data", "{$site_url}/admin/online/ajax_shishi"); so.write("my_chart"); } test(); setInterval(function(){ var tmp = findSWF("ofc"); tmp.reload('{$site_url}/admin/online/ajax_shishi',false); },2000); </script> </body> </html>
ajax_shishi.html
&variables=true& &title=今日注册统计,{text-align:right; font-size:12px; color: #00FF00; margin: 12px; background-color: #000090; padding:10px;}& &y_legendx=tongji,16,#7E97A6& &y_label_size=20& &y_ticks=5,10,4& &bar=50,0x9933CC,Page views,10& &values={$values}& &x_labels=January,February,March,April,May,June,July,August,Spetember,October,November,December& &x_labels_size=30& &x_label_style=10, '0x000000', 1, 1& &x_axis_steps=2& &y_max=20&