实现仿流量统计地区分布 flash 饼状分析图代码实例
今天给大家分享一个 flash 动画效果饼状地区分布图。用过流量统计的朋友都知道,流量统计中的地域分布状图很给力,当鼠标移动到某个区域,那个区域就会自动分离。正如下面效果图片所示:
本文所用到的数据表及插件下载地址: http://www.jb100.net/html/content-28-373-1.html
从以上地址下载所需要的资料后下,将数据表导入数据库,将charts文件放到public文件夹下。
下面废话少说就直接上代码了 ,PHP代码: public function fenbu(){<br>
$this->checkuser('stats_dq');<br>
$end_date =strtotime(date('Y-m-d',time()));<br>
$start_date = $end_date-31536000;<br>
$area_xml = "<graph>";<br>
$sql = "SELECT COUNT(*) AS access_count, area FROM ja_stats " .<br>
" WHERE access_time >= '$start_date' AND access_time
" GROUP BY area ORDER BY access_count DESC LIMIT 20";<br>
$res = M('stats')->query($sql);<br>
$key=0;<br>
foreach ($res as $val){<br>
$area = empty($val['area']) ? 'unknow' : $val['area'];<br>
$area_xml .= "<set>chart_color($key). "' />";<br>
$key++;<br>
}<br>
$area_xml .= '</set></graph>';<br>
<br>
$from_xml = "<graph>";<br>
<br>
$sql = "SELECT COUNT(*) AS access_count, source_url FROM ja_stats " .<br>
" WHERE access_time >= '$start_date' AND access_time
" GROUP BY source_url ORDER BY access_count DESC LIMIT 20";<br>
$res = M('stats')->query($sql);<br>
$key=0;<br>
foreach ($res as $val){<br>
$from = empty($val['source_url']) ? '直接输入网址' : $val['source_url'];<br>
$from_xml .= "<set>chart_color($key). "' />";<br>
$key++;<br>
}<br>
$from_xml .= '</set></graph>';<br>
<br>
<br>
$this->assign('from_data', $from_xml);<br>
<br>
$this->assign('area_data', $area_xml);<br>
<br>
$this->display(); <br>
}<br>
public function chart_color($n){<br>
/* 随机显示颜色代码 */<br>
$arr = array('33FF66', 'FF6600', '3399FF', '009966', 'CC3399', 'FFCC33', '6699CC', 'CC3366', '33FF66', 'FF6600', '3399FF');<br>
<br>
if ($n > 8){<br>
$n = $n % 8;<br>
}<br>
return $arr[$n];<br>
}<br>
HTML代码: <div>地区分布</div>
<br>
<div>
<br>
<object><br>
<param>
<br>
<param>
<br>
<param>
<br>
<param>
<br>
<param>
<br>
<embed></embed><br>
</object> <br>
<br>
</div>
本文所用到的数据表及插件下载地址:http://www.jb100.net/html/content-28-373-1.html
希望本文所述对大家有所帮助,也希望大家继续关注我!
AD:真正免费,域名+虚机+企业邮箱=0元