样式比较简单 功能实现了 和大家共享
这个地址里面有好多插件可以用 圆柱 折线 等等 大家可以去参考 开发
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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/ css 代码 /
</style>
<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/oldie.js"></script>
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
<script src="https://img.hcharts.cn/highcharts/themes/sand-signika.js"></script>
</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();
}
}
数据表:
![](https://s1.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=)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。