Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
workbiu-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gxx
workbiu-admin
Commits
4df8c4f2
Commit
4df8c4f2
authored
Nov 15, 2017
by
gxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成用户参与度部分显示
parent
8698e6c6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
332 additions
and
61 deletions
+332
-61
StatisticsController.php
app/Http/Controllers/StatisticsController.php
+26
-5
TestController.php
app/Http/Controllers/TestController.php
+45
-0
StatisticsService.php
app/Services/StatisticsService.php
+29
-24
UserFactory.php
database/factories/UserFactory.php
+42
-5
DatabaseSeeder.php
database/seeds/DatabaseSeeder.php
+1
-0
UserInfoTableSeeder.php
database/seeds/UserInfoTableSeeder.php
+16
-0
dashboard.blade.php
resources/views/admin/dashboard.blade.php
+6
-4
index.blade.php
resources/views/admin/index.blade.php
+162
-19
web.php
routes/web.php
+5
-4
No files found.
app/Http/Controllers/StatisticsController.php
View file @
4df8c4f2
...
@@ -6,6 +6,7 @@ use App\Contracts\StatisticsServiceContract;
...
@@ -6,6 +6,7 @@ use App\Contracts\StatisticsServiceContract;
use
App\Models\Group
;
use
App\Models\Group
;
use
App\Models\Project
;
use
App\Models\Project
;
use
App\Models\User
;
use
App\Models\User
;
use
App\Models\UserInfo
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
...
@@ -25,13 +26,13 @@ class StatisticsController extends Controller
...
@@ -25,13 +26,13 @@ class StatisticsController extends Controller
$startData
=
Carbon
::
today
();
$startData
=
Carbon
::
today
();
// 查询 今日新增用户
// 查询 今日新增用户
$newUserCount
=
count
(
User
::
where
(
'created_at'
,
'>'
,
$startData
)
->
get
());
$newUserCount
=
count
(
User
Info
::
where
(
'created_at'
,
'>'
,
$startData
)
->
get
());
// 查询今日新增项目
// 查询今日新增项目
$newProject
=
count
(
Project
::
where
(
'created_at'
,
'>'
,
$startData
)
->
get
());
$newProject
=
count
(
Project
::
where
(
'created_at'
,
'>'
,
$startData
)
->
get
());
// 查询所有用户
// 查询所有用户
$users
=
count
(
User
::
all
());
$users
=
count
(
User
Info
::
all
());
// 查询所有项目
// 查询所有项目
$projects
=
count
(
Project
::
all
());
$projects
=
count
(
Project
::
all
());
...
@@ -49,7 +50,7 @@ class StatisticsController extends Controller
...
@@ -49,7 +50,7 @@ class StatisticsController extends Controller
}
}
//
获取
用户信息
//
活跃
用户信息
public
function
ActiveUser
()
public
function
ActiveUser
()
{
{
$data
=
$this
->
mStatistics
->
ActiveUser
();
$data
=
$this
->
mStatistics
->
ActiveUser
();
...
@@ -72,7 +73,7 @@ class StatisticsController extends Controller
...
@@ -72,7 +73,7 @@ class StatisticsController extends Controller
return
$returnVisitUsersCount
;
return
$returnVisitUsersCount
;
}
}
// 用户存留
public
function
UserRetention
()
public
function
UserRetention
()
{
{
$data
=
$this
->
mStatistics
->
UserRetention
();
$data
=
$this
->
mStatistics
->
UserRetention
();
...
@@ -106,7 +107,27 @@ class StatisticsController extends Controller
...
@@ -106,7 +107,27 @@ class StatisticsController extends Controller
// 用户参与度
// 用户参与度
public
function
UserEngagement
()
public
function
UserEngagement
()
{
{
$data
=
$this
->
mStatistics
->
UserEngagement
();
$engagement
=
$this
->
mStatistics
->
UserEngagement
();
$data
=
[];
foreach
(
$engagement
as
$key
=>
$v
){
$data
[
0
][]
=
$key
;
$data
[
1
][]
=
[
'value'
=>
$v
,
'name'
=>
$key
];
}
return
$data
;
}
// 统计 流失用户、月活跃用户、月新增用户、回访用户
public
function
Total
()
{
$returnVisitUser
=
$this
->
mStatistics
->
ReturnVisit
();
$outFlowUser
=
$this
->
mStatistics
->
OutflowUser
();
$activeUser
=
$this
->
mStatistics
->
ActiveUser
();
$userIncrease
=
$this
->
mStatistics
->
UserIncrease
();
$data
[
0
]
=
[
'回访用户'
,
'流失用户'
,
'月活跃用户'
];
$data
[
1
]
=
array
([
'value'
=>
$returnVisitUser
[
'回访用户'
],
'name'
=>
'回访用户'
],[
'value'
=>
$outFlowUser
[
'流失用户'
],
'name'
=>
'流失用户'
],[
'value'
=>
$activeUser
[
'上一个月活跃用户'
],
'name'
=>
'月活跃用户'
]);
return
$data
;
return
$data
;
}
}
...
...
app/Http/Controllers/TestController.php
0 → 100644
View file @
4df8c4f2
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
class
TestController
extends
Controller
{
public
function
test
()
{
$arr
=
array
([
'id'
=>
"1"
,
'time'
=>
"3"
],[
'id'
=>
"2"
,
'time'
=>
"5"
],[
'id'
=>
"3"
,
'time'
=>
"3"
],[
'id'
=>
"4"
,
'time'
=>
"5"
],[
'id'
=>
"5"
,
'time'
=>
"3"
],[
'id'
=>
"6"
,
'time'
=>
"6"
],[
'id'
=>
"7"
,
'time'
=>
"3"
],[
'id'
=>
"8"
,
'time'
=>
"2"
],[
'id'
=>
"9"
,
'time'
=>
"6"
],[
'id'
=>
"1"
,
'time'
=>
"5"
]);
$arrA
=
array
([
'name'
=>
'group'
],[
'name'
=>
'project'
],[
'name'
=>
'task'
],[
'name'
=>
'schedule'
],[
'name'
=>
'board'
]);
$terminal
=
[
'pc'
,
'android'
,
'iPhone'
];
$data
=
array_rand
(
$arr
,
3
);
$dataA
=
array_rand
(
$arrA
,
3
);
$dataB
=
array_rand
(
$terminal
,
1
);
$data_last
=
[];
foreach
(
$data
as
$a
){
$data_last
[]
=
$arr
[
$a
];
}
$aa
=
json_encode
(
$data_last
);
$data_lastA
=
[];
foreach
(
$dataA
as
$a
){
$data_lastA
[]
=
$arrA
[
$a
];
}
$b
=
json_encode
(
$data_lastA
);
dd
(
$terminal
[
$dataB
]);
}
}
app/Services/StatisticsService.php
View file @
4df8c4f2
...
@@ -31,6 +31,7 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -31,6 +31,7 @@ class StatisticsService implements StatisticsServiceContract
}
}
// 新增用户
public
function
UserIncrease
()
public
function
UserIncrease
()
{
{
$startTime
=
strtotime
(
date
(
'Ymd'
))
-
86400
;
$startTime
=
strtotime
(
date
(
'Ymd'
))
-
86400
;
...
@@ -39,13 +40,17 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -39,13 +40,17 @@ class StatisticsService implements StatisticsServiceContract
$dtM
=
date
(
"Y-m-d H:i:s"
,
mktime
(
0
,
0
,
0
,
date
(
"m"
)
-
1
,
1
,
date
(
"Y"
)));
$dtM
=
date
(
"Y-m-d H:i:s"
,
mktime
(
0
,
0
,
0
,
date
(
"m"
)
-
1
,
1
,
date
(
"Y"
)));
$dtW
=
date
(
"Y-m-d H:i:s"
,
mktime
(
0
,
0
,
0
,
date
(
"m"
),
date
(
"d"
)
-
date
(
"w"
)
+
1
-
7
,
date
(
"Y"
)));
$dtW
=
date
(
"Y-m-d H:i:s"
,
mktime
(
0
,
0
,
0
,
date
(
"m"
),
date
(
"d"
)
-
date
(
"w"
)
+
1
-
7
,
date
(
"Y"
)));
$dayUsers
=
User
::
where
(
'created_at'
,
'>'
,
$start
)
->
where
(
function
(
$query
){
$dayUsers
=
User
Info
::
where
(
'created_at'
,
'>'
,
$start
)
->
where
(
function
(
$query
){
$query
->
where
(
'created_at'
,
'<'
,
date
(
'Y-m-d H:i:s'
,
strtotime
(
date
(
'Ymd'
))));
$query
->
where
(
'created_at'
,
'<'
,
date
(
'Y-m-d H:i:s'
,
strtotime
(
date
(
'Ymd'
))));
})
->
get
();
})
->
get
();
$monthUsers
=
User
::
where
(
'created_at'
,
'>'
,
$dtM
)
->
get
();
$monthUsers
=
UserInfo
::
where
(
'created_at'
,
'>'
,
$dtM
)
->
get
();
$weekUsers
=
User
::
where
(
'created_at'
,
'>'
,
$dtW
)
->
get
();
$weekUsers
=
UserInfo
::
where
(
'created_at'
,
'>'
,
$dtW
)
$users
=
User
::
all
()
->
count
();
->
where
(
function
(
$query
){
$query
->
where
(
'created_at'
,
'<'
,
date
(
"Y-m-d H:i:s"
,
mktime
(
23
,
59
,
59
,
date
(
"m"
),
date
(
"d"
)
-
date
(
"w"
)
+
7
-
7
,
date
(
"Y"
))));
})
->
get
();
$users
=
UserInfo
::
all
()
->
count
();
$day
=
0
;
$day
=
0
;
$week
=
0
;
$week
=
0
;
$month
=
0
;
$month
=
0
;
...
@@ -59,12 +64,12 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -59,12 +64,12 @@ class StatisticsService implements StatisticsServiceContract
$month
=
count
(
$monthUsers
);
$month
=
count
(
$monthUsers
);
}
}
$day
=
ceil
(
round
(
$day
/
$users
*
100
,
2
))
;
$dayUser
=
ceil
(
$day
/
$users
*
100
);
$week
=
ceil
(
round
(
$week
/
$users
*
100
,
2
))
;
$weekUser
=
ceil
(
$week
/
$users
*
100
)
;
$month
=
ceil
(
round
(
$month
/
$users
*
100
,
2
))
;
$monthUser
=
ceil
(
$month
/
$users
*
100
)
;
$date
=
[
'昨日新增用户占比'
=>
$dayUser
,
'上一周新增用户占比'
=>
$weekUser
,
'上一个月新增用户占比'
=>
$monthUser
];
$date
=
array
(
$day
.
'%'
,
$week
.
'%'
,
$month
.
'%'
);
// $date = array(['昨日新增用户占比'=>$day.'%','上一周新增用户占比'=>$week.'%','上一个月新增用户占比'=>$month.'%']);
return
$date
;
return
$date
;
}
}
...
@@ -202,11 +207,12 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -202,11 +207,12 @@ class StatisticsService implements StatisticsServiceContract
$activeUsers
=
$this
->
ActiveUser
();
$activeUsers
=
$this
->
ActiveUser
();
$outflowUsers
=
$this
->
OutflowUser
();
$outflowUsers
=
$this
->
OutflowUser
();
$userTotals
=
$this
->
UserTotal
();
$userTotals
=
$this
->
UserTotal
();
$outflow
=
ceil
(
$outflowUsers
[
'流失用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$outflow
=
ceil
(
$outflowUsers
[
'流失用户'
]
/
$userTotals
[
'全部用户'
]
*
100
)
;
$dayActive
=
ceil
(
$activeUsers
[
'昨日活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$dayActive
=
ceil
(
$activeUsers
[
'昨日活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
)
;
$monthActive
=
ceil
(
$activeUsers
[
'上一个月活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$monthActive
=
ceil
(
$activeUsers
[
'上一个月活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
)
;
$weekActive
=
ceil
(
$activeUsers
[
'上一周活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
);
$weekActive
=
ceil
(
$activeUsers
[
'上一周活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
);
$data
=
[
'昨日活跃占比'
=>
$dayActive
.
'%'
,
'上一个月活跃占比'
=>
$monthActive
.
'%'
,
'上一周活跃占比'
=>
$weekActive
.
'%'
,
'流失用户占比'
=>
$outflow
.
'%'
];
$data
[
'No%'
]
=
[
'昨日活跃占比'
=>
$dayActive
,
'上一个月活跃占比'
=>
$monthActive
,
'上一周活跃占比'
=>
$weekActive
,
'流失用户占比'
=>
$outflow
];
$data
[
'%'
]
=
[
'昨日活跃占比'
=>
$dayActive
.
'%'
,
'上一个月活跃占比'
=>
$monthActive
.
'%'
,
'上一周活跃占比'
=>
$weekActive
.
'%'
,
'流失用户占比'
=>
$outflow
.
'%'
];
return
$data
;
return
$data
;
}
}
...
@@ -215,7 +221,7 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -215,7 +221,7 @@ class StatisticsService implements StatisticsServiceContract
// 用户平均创建参与
// 用户平均创建参与
public
function
AverageUserOperation
()
public
function
AverageUserOperation
()
{
{
$users
=
User
::
all
();
$users
=
User
Info
::
all
();
$creatorGroupCount
=
0
;
$creatorGroupCount
=
0
;
$participateGroupCount
=
0
;
$participateGroupCount
=
0
;
...
@@ -308,12 +314,12 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -308,12 +314,12 @@ class StatisticsService implements StatisticsServiceContract
}
if
(
$page
->
id
==
3
){
}
if
(
$page
->
id
==
3
){
$c
+=
$page
->
time
;
$c
+=
$page
->
time
;
}
if
(
$page
->
id
==
4
){
}
if
(
$page
->
id
==
4
){
$d
+=
$page
->
time
;
$d
+=
$page
->
time
;
}
if
(
$page
->
id
==
5
){
}
if
(
$page
->
id
==
5
){
$e
+=
$page
->
time
;
$e
+=
$page
->
time
;
}
if
(
$page
->
id
==
6
){
}
if
(
$page
->
id
==
6
){
$f
+=
$page
->
time
;
$f
+=
$page
->
time
;
}
if
(
$page
->
id
==
7
){
}
if
(
$page
->
id
==
7
){
$g
+=
$page
->
time
;
$g
+=
$page
->
time
;
}
if
(
$page
->
id
==
8
){
}
if
(
$page
->
id
==
8
){
$h
+=
$page
->
time
;
$h
+=
$page
->
time
;
...
@@ -431,15 +437,14 @@ class StatisticsService implements StatisticsServiceContract
...
@@ -431,15 +437,14 @@ class StatisticsService implements StatisticsServiceContract
// 获取全部用户
// 获取全部用户
$userCount
=
count
(
$users
);
$userCount
=
count
(
$users
);
$engagementGroup
=
ceil
(
$group
/
$userCount
*
100
)
.
'%'
;
$engagementGroup
=
ceil
(
$group
/
$userCount
*
100
);
$engagementProject
=
ceil
(
$project
/
$userCount
*
100
)
.
'%'
;
$engagementProject
=
ceil
(
$project
/
$userCount
*
100
);
$engagementTask
=
ceil
(
$task
/
$userCount
*
100
)
.
'%'
;
$engagementTask
=
ceil
(
$task
/
$userCount
*
100
);
$engagementSchedule
=
ceil
(
$schedule
/
$userCount
*
100
)
.
'%'
;
$engagementSchedule
=
ceil
(
$schedule
/
$userCount
*
100
);
$engagementBoard
=
ceil
(
$board
/
$userCount
*
100
)
.
'%'
;
$engagementBoard
=
ceil
(
$board
/
$userCount
*
100
);
$data
=
[
'
group'
=>
$engagementGroup
,
'project'
=>
$engagementProject
,
'task'
=>
$engagementTask
,
'schedule'
=>
$engagementSchedule
,
'board
'
=>
$engagementBoard
];
$data
=
[
'
团队'
=>
$engagementGroup
,
'项目'
=>
$engagementProject
,
'任务'
=>
$engagementTask
,
'日程'
=>
$engagementSchedule
,
'看板
'
=>
$engagementBoard
];
return
$data
;
return
$data
;
dd
(
$engagementGroup
,
$engagementProject
,
$engagementTask
,
$engagementSchedule
,
$engagementBoard
);
}
}
...
...
database/factories/UserFactory.php
View file @
4df8c4f2
...
@@ -13,13 +13,50 @@ use Faker\Generator as Faker;
...
@@ -13,13 +13,50 @@ use Faker\Generator as Faker;
|
|
*/
*/
$factory
->
define
(
App\User
::
class
,
function
(
Faker
$faker
)
{
//$factory->define(App\User::class, function (Faker $faker) {
// static $password;
//
// return [
// 'name' => $faker->name,
// 'email' => $faker->unique()->safeEmail,
// 'password' => $password ?: $password = bcrypt('secret'),
// 'remember_token' => str_random(10),
// ];
//});
$factory
->
define
(
App\Models\UserInfo
::
class
,
function
(
Faker
$faker
)
{
static
$password
;
static
$password
;
$terminal
=
[
'pc'
,
'android'
,
'iPhone'
];
$dataB
=
array_rand
(
$terminal
,
1
);
$arr
=
array
([
'id'
=>
"1"
,
'time'
=>
"3"
],[
'id'
=>
"2"
,
'time'
=>
"5"
],[
'id'
=>
"3"
,
'time'
=>
"3"
],[
'id'
=>
"4"
,
'time'
=>
"5"
],[
'id'
=>
"5"
,
'time'
=>
"3"
],[
'id'
=>
"6"
,
'time'
=>
"6"
],[
'id'
=>
"7"
,
'time'
=>
"3"
],[
'id'
=>
"8"
,
'time'
=>
"2"
],[
'id'
=>
"9"
,
'time'
=>
"6"
],[
'id'
=>
"1"
,
'time'
=>
"5"
]);
$data
=
array_rand
(
$arr
,
3
);
$data_last
=
[];
foreach
(
$data
as
$a
){
$data_last
[]
=
$arr
[
$a
];
}
$aa
=
json_encode
(
$data_last
);
$arrA
=
array
([
'name'
=>
'group'
],[
'name'
=>
'project'
],[
'name'
=>
'task'
],[
'name'
=>
'schedule'
],[
'name'
=>
'board'
]);
$dataA
=
array_rand
(
$arrA
,
3
);
$data_lastA
=
[];
foreach
(
$dataA
as
$a
){
$data_lastA
[]
=
$arrA
[
$a
];
}
$b
=
json_encode
(
$data_lastA
);
$user
=
5
;
return
[
return
[
'name'
=>
$faker
->
name
,
'user_id'
=>
$user
++
,
'email'
=>
$faker
->
unique
()
->
safeEmail
,
'manner'
=>
'phone'
,
'password'
=>
$password
?:
$password
=
bcrypt
(
'secret'
),
'terminal'
=>
$terminal
[
$dataB
],
'remember_token'
=>
str_random
(
10
),
'last_login_time'
=>
date
(
'Y-m-d H:i:s'
),
'page_retention_time'
=>
$aa
,
'user_engagement'
=>
$b
,
'return_visit'
=>
'1'
,
];
];
});
});
database/seeds/DatabaseSeeder.php
View file @
4df8c4f2
...
@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
...
@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
public
function
run
()
public
function
run
()
{
{
// $this->call(UsersTableSeeder::class);
// $this->call(UsersTableSeeder::class);
$this
->
call
(
UserInfoTableSeeder
::
class
);
}
}
}
}
database/seeds/UserInfoTableSeeder.php
0 → 100644
View file @
4df8c4f2
<?php
use
Illuminate\Database\Seeder
;
class
UserInfoTableSeeder
extends
Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public
function
run
()
{
factory
(
\App\Models\UserInfo
::
class
,
10
)
->
create
();
}
}
resources/views/admin/dashboard.blade.php
View file @
4df8c4f2
...
@@ -67,7 +67,7 @@ desired effect
...
@@ -67,7 +67,7 @@ desired effect
<!-- Content Wrapper. Contains page content -->
<!-- Content Wrapper. Contains page content -->
<div
class=
"content-wrapper"
>
<div
class=
"content-wrapper"
style=
"min-height: 100%"
>
<!-- Content Header (Page header) -->
<!-- Content Header (Page header) -->
{{--
<section
class=
"content-header"
>
--}}
{{--
<section
class=
"content-header"
>
--}}
{{--
<h1>
--}}
{{--
<h1>
--}}
...
@@ -81,11 +81,13 @@ desired effect
...
@@ -81,11 +81,13 @@ desired effect
{{--
</section>
--}}
{{--
</section>
--}}
<!-- Main content -->
<!-- Main content -->
<div
style=
"height: auto;overflow: hidden;"
>
<section
class=
"content"
>
<section
class=
"content"
>
@yield('content')
@yield('content')
</section>
</section>
</div>
<!-- /.content -->
<!-- /.content -->
</div>
</div>
<!-- /.content-wrapper -->
<!-- /.content-wrapper -->
...
...
resources/views/admin/index.blade.php
View file @
4df8c4f2
...
@@ -67,12 +67,12 @@
...
@@ -67,12 +67,12 @@
<!--
./
col
-->
<!--
./
col
-->
</
div
>
</
div
>
<
div
>
<
div
class
=
"row"
>
{{
--<
div
style
=
"width: 728px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;"
>--
}}
{{
--<
div
style
=
"width: 728px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;"
>--
}}
<
div
style
=
"width: 808px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;margin-top: 70px
"
>
<
div
class
=
"col-lg-6 col-md-12"
style
=
"width: 808px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;margin: 70px 15px 0 0;
"
>
<
p
style
=
"margin-left: 265px;"
>
新增用户占总用户百分比数据图
</
p
>
<
p
style
=
"margin-left: 265px;"
>
新增用户占总用户百分比数据图
</
p
>
...
@@ -90,14 +90,60 @@
...
@@ -90,14 +90,60 @@
</
div
>
</
div
>
</
div
>
<
div
class
=
"col-lg-6 col-md-12"
style
=
"float: left;"
>
{{
--<
p
style
=
"margin-left: 45%;margin-top: 5%"
>
大数据
!
</
p
>--
}}
<!--
为ECharts准备一个具备大小
(
宽高
)
的Dom
-->
<!--
为ECharts准备一个具备大小
(
宽高
)
的Dom
-->
<
div
id
=
"main"
style
=
"width: 600px;height:400px;"
></
div
>
</
div
>
</
div
>
<
div
class
=
"row"
>
{{
--<
div
style
=
"width: 728px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;"
>--
}}
<
div
class
=
"col-lg-6 col-md-12"
style
=
"width: 808px;height: 200px;background-color: #f0f0f0;border: 1px solid #D2D6DE;float: right;margin: 70px 15px 0 0;"
>
<
p
style
=
"margin-left: 265px;"
>
新增用户占总用户百分比数据图666
</
p
>
<
div
style
=
"width: 220px;height: 150px;float: left; margin-top:2px;margin-left: 15px; line-height: 150px;"
>
昨日新增用户数
:
<
span
style
=
"font-family:'微软雅黑';font-size: 20px;color: #cb2027;"
id
=
"day"
>
</
span
>
</
div
>
<
div
style
=
"float:left;width: 1px;height: 120px; background: #A3A3A3;margin-top: 21px;"
></
div
>
<
div
style
=
"width: 220px;height: 150px;float: left; margin-top: 2px;margin-left: 15px;line-height: 150px;"
>
一周内新增用户数
:
<
span
style
=
"font-family:'微软雅黑';font-size: 20px;color: #cb2027;"
id
=
"week"
>
</
span
>
</
div
>
<
div
style
=
"float:left;width: 1px;height: 120px; background: #A3A3A3;margin-top: 21px;"
></
div
>
<
div
style
=
"width: 220px;height: 150px;float: left; margin-top: 2px;margin-left: 15px;line-height: 150px;"
>
一月内新增用户数
:
<
span
style
=
"font-family:'微软雅黑';font-size: 20px;color: #cb2027;"
id
=
"month"
>
</
span
>
</
div
>
</
div
>
<
div
id
=
"main"
style
=
"width: 600px;height:400px;"
></
div
>
</
div
>
<
div
class
=
"col-lg-6 col-md-12"
style
=
"float: left;"
>
<!--
为ECharts准备一个具备大小
(
宽高
)
的Dom
-->
<
div
id
=
"user_engagement"
style
=
"width: 600px;height:400px;"
></
div
>
</
div
>
</
div
>
</
div
>
<
script
src
=
"
{
{url('js/jquery-3.2.1.min.js')}
}
"
>
</
script
>
<
script
src
=
"
{
{url('js/jquery-3.2.1.min.js')}
}
"
>
</
script
>
<!--
引入
echarts
.
js
-->
<!--
引入
echarts
.
js
-->
...
@@ -105,27 +151,73 @@
...
@@ -105,27 +151,73 @@
<
script
>
<
script
>
// 基于准备好的dom,初始化echarts实例
var
myChart
=
echarts
.
init
(
document
.
getElementById
(
'main'
));
var
user_engagement_myChart
=
echarts
.
init
(
document
.
getElementById
(
'user_engagement'
));
UserIncrease
();
function
UserIncrease
(){
$
.
ajax
({
$
.
ajax
({
type
:
'get'
,
type
:
'get'
,
url
:
'{{route('
statistics
.
UserIncrease
')}}'
,
url
:
'{{route('
statistics
.
UserIncrease
')}}'
,
success
:
function
(
data
){
success
:
function
(
data
){
$
(
'#day'
)
.
html
(
data
[
0
]);
//console.log(data);
$
(
'#week'
)
.
html
(
data
[
1
]);
$
(
'#day'
)
.
html
(
data
[
'昨日新增用户占比'
]
+
'%'
);
$
(
'#month'
)
.
html
(
data
[
2
]);
$
(
'#week'
)
.
html
(
data
[
'上一周新增用户占比'
]
+
'%'
);
$
(
'#month'
)
.
html
(
data
[
'上一个月新增用户占比'
]
+
'%'
);
},
},
error
:
function
(
data
){
error
:
function
(
data
){
console
.
log
(
'错误'
);
console
.
log
(
'错误'
);
}
}
});
});
}
total
();
function
total
(){
$
.
ajax
({
type
:
'get'
,
url
:
"
{
{route('statistics.Total')}
}
"
,
success
:
function
(
data
){
optiona
[
'legend'
][
'data'
]
=
data
[
0
];
optiona
[
'series'
][
0
][
'data'
]
=
data
[
1
];
//console.log(optiona['series'][0]['data'])
myChart
.
setOption
(
optiona
);
},
error
:
function
(
data
)
{
console
.
log
(
data
);
}
})
}
user_engagement
();
function
user_engagement
(){
$
.
ajax
({
type
:
'get'
,
url
:
"
{
{route('statistics.UserEngagement')}
}
"
,
success
:
function
(
data
){
console
.
log
(
data
);
option_user_engagement
[
'legend'
][
'data'
]
=
data
[
0
]
;
console
.
log
(
option_user_engagement
[
'series'
][
0
][
'data'
]);
console
.
log
(
option_user_engagement
[
'series'
][
0
][
'data'
]
=
data
[
1
]);
console
.
log
(
option_user_engagement
[
'series'
][
0
][
'data'
]);
user_engagement_myChart
.
setOption
(
option_user_engagement
);
// 基于准备好的dom,初始化echarts实例
},
var
myChart
=
echarts
.
init
(
document
.
getElementById
(
'main'
));
error
:
function
(
data
)
{
console
.
log
(
data
);
}
})
}
var
optiona
=
{
var
optiona
=
{
title
:
{
text
:
'流失、活跃、回访占比'
,
//subtext: '纯属虚构',
x
:
'center'
},
tooltip
:
{
tooltip
:
{
trigger
:
'item'
,
trigger
:
'item'
,
formatter
:
"
{
a
}
<br/>
{
b
}
:
{
c
}
(
{
d
}
%)"
formatter
:
"
{
a
}
<br/>
{
b
}
:
{
c
}
(
{
d
}
%)"
...
@@ -133,11 +225,11 @@
...
@@ -133,11 +225,11 @@
legend
:
{
legend
:
{
orient
:
'vertical'
,
orient
:
'vertical'
,
x
:
'left'
,
x
:
'left'
,
data
:
[
'直接访问'
,
'邮件营销'
,
'联盟广告'
,
'视频广告'
,
'搜索引擎'
]
},
},
series
:
[
series
:
[
{
{
name
:
'
访问来源
'
,
name
:
'
简单统计
'
,
type
:
'pie'
,
type
:
'pie'
,
radius
:
[
'50%'
,
'70%'
],
radius
:
[
'50%'
,
'70%'
],
avoidLabelOverlap
:
false
,
avoidLabelOverlap
:
false
,
...
@@ -158,18 +250,69 @@
...
@@ -158,18 +250,69 @@
normal
:
{
normal
:
{
show
:
false
show
:
false
}
}
}
}
]
};
var
option_user_engagement
=
{
title
:
{
text
:
'用户参与进度'
,
//subtext: '纯属虚构',
x
:
'center'
},
tooltip
:
{
trigger
:
'item'
,
formatter
:
"
{
a
}
<br/>
{
b
}
:
{
c
}
(
{
d
}
%)"
},
legend
:
{
orient
:
'vertical'
,
left
:
'left'
,
data
:
[
'直接访问'
,
'邮件营销'
,
'联盟广告'
,
'视频广告'
,
'搜索引擎'
]
},
},
series
:
[
{
name
:
'访问来源'
,
type
:
'pie'
,
radius
:
'55%'
,
center
:
[
'50%'
,
'60%'
],
data
:
[
data
:
[
{
value
:
335
,
name
:
'直接访问'
},
{
value
:
335
,
name
:
'直接访问'
},
{
value
:
310
,
name
:
'邮件营销'
},
{
value
:
310
,
name
:
'邮件营销'
},
{
value
:
234
,
name
:
'联盟广告'
},
{
value
:
234
,
name
:
'联盟广告'
},
{
value
:
135
,
name
:
'视频广告'
},
{
value
:
135
,
name
:
'视频广告'
},
{
value
:
1548
,
name
:
'搜索引擎'
}
{
value
:
1548
,
name
:
'搜索引擎'
}
]
],
itemStyle
:
{
emphasis
:
{
shadowBlur
:
10
,
shadowOffsetX
:
0
,
shadowColor
:
'rgba(0, 0, 0, 0.5)'
}
}
}
}
]
]
};
};
myChart
.
setOption
(
optiona
);
</
script
>
</
script
>
...
...
routes/web.php
View file @
4df8c4f2
...
@@ -21,18 +21,19 @@ Route::get('statistics','StatisticsController@newUser');
...
@@ -21,18 +21,19 @@ Route::get('statistics','StatisticsController@newUser');
Route
::
get
(
'admin'
,
function
(){
Route
::
get
(
'admin'
,
function
(){
return
view
(
'Admin-lte/dashboard'
);
return
view
(
'Admin-lte/dashboard'
);
});
});
Auth
::
routes
();
Auth
::
routes
();
Route
::
get
(
'/home'
,
'HomeController@index'
)
->
name
(
'home'
);
Route
::
get
(
'/home'
,
'HomeController@index'
)
->
name
(
'home'
);
// 短信
// 短信
Route
::
get
(
'sms'
,
'SMSController@surplus'
);
Route
::
get
(
'sms'
,
'SMSController@surplus'
);
// 测试路由
Route
::
get
(
'test'
,
'Testcontroller@test'
)
->
name
(
'test'
);
// 用户
// 用户
...
@@ -90,7 +91,7 @@ Route::group(['prefix'=> 'statistics'],function (){
...
@@ -90,7 +91,7 @@ Route::group(['prefix'=> 'statistics'],function (){
Route
::
get
(
'retention_time'
,
'StatisticsController@RetentionTime'
)
->
name
(
'statistics.RetentionTime'
);
Route
::
get
(
'retention_time'
,
'StatisticsController@RetentionTime'
)
->
name
(
'statistics.RetentionTime'
);
Route
::
get
(
'new_user'
,
'StatisticsController@NewUsers'
)
->
name
(
'statistics.NewUser'
);
Route
::
get
(
'new_user'
,
'StatisticsController@NewUsers'
)
->
name
(
'statistics.NewUser'
);
Route
::
get
(
'user_engagement'
,
'StatisticsController@UserEngagement'
)
->
name
(
'statistics.UserEngagement'
);
Route
::
get
(
'user_engagement'
,
'StatisticsController@UserEngagement'
)
->
name
(
'statistics.UserEngagement'
);
Route
::
get
(
'total'
,
'StatisticsController@Total'
)
->
name
(
'statistics.Total'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment