tp5基於js折線圖插件統計會員註冊數量

樣式比較簡單 功能實現了 和大家共享
tp5基於js折線圖插件統計會員註冊數量

這個地址裏面有好多插件可以用 圓柱 折線 等等 大家可以去參考 開發
https://bbs.hcharts.cn/forum.php

上代碼(第一版本還有好多地方處理的不周到,大家可以自行改進)
html+插件js代碼 繼續優化迭代
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"><link rel="icon" href="https://static.jianshukeji.com/highcharts/images/favicon.ico"&gt;
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/ css 代碼 /
</style>
<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script&gt;
<script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script&gt;
<script src="https://img.hcharts.cn/highcharts/modules/oldie.js"></script&gt;
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script&gt;
<script src="https://img.hcharts.cn/highcharts/themes/sand-signika.js"></script&gt;
</head>
<body>
<div id="container" style="min-width:400px;height:400px"></div>
<script type="text/javascript" src="/static/index/js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="/static/index/js/gw-2.js"></script>
<script>
$.ajax({
type:"post",
url :"{:url('user/user_gy')}",
data :"list:0,list:1",
dataType:"json",
success:function(data){
/ var i = 0;
for(i;i<data.length;i++){
var d_time = data[i].date;
var count = data[i].count;
}
/
var chart = Highcharts.chart('container', {
chart: {
type: 'line'
},
title: {
text: '註冊會員統計'
},
subtitle: {
text: '數據來源:嬌美夫集團 '
},
xAxis: {

                    categories: [data[0].date,data[1].date]
            },
            yAxis: {
                title: {
                    text: '人數(個)'
                }
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        // 開啓數據標籤
                        enabled: true
                    },
                    // 關閉鼠標跟蹤,對應的提示框、點擊事件會失效
                    enableMouseTracking: false
                }
            },
            series: [{
                name: '會員量',
                data: [data[0].count,data[1].count]
            }]
        });

    }
});

</script>
</body>
</html>

基於tp5框架開發
控制器
public function user_gy(){
if(request()->isPost()){
$time = date("Y-m-d");
$j_t =time();
$lastM =date("Y-m-d",strtotime("$time -1 month"));
$new_T =strtotime($lastM);
$user = Db::name("User")
->field("count(id) as count,FROM_UNIXTIME(update_time,'%Y-%m-%d') as date")
->where("status = 1 and update_time <= '$j_t' and update_time >= '$new_T'")
->group("date")
->select();
return json($user);
}else{

          return $this->fetch();
      }

}

    數據表:
    ![](http://i2.51cto.com/images/blog/201808/02/45df760c594c76c6117e5eb26d1bc27e.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章