增加天流量趋势,并优化首页图表样式
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<script type="text/javascript" src="../assets/libs/echarts.min.js"></script>
|
||||
<style>
|
||||
.layui-card-header {
|
||||
text-align:left;
|
||||
@@ -20,6 +19,22 @@
|
||||
font-size: 250%;
|
||||
height: 30px;
|
||||
}
|
||||
.my-tab-item {
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
margin-right: 20px;
|
||||
padding: 0 15px 12px 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.my-tab-item-select {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
border-bottom: 2px solid #5FB878;
|
||||
}
|
||||
.my-tab-content {
|
||||
height: 300px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -80,8 +95,13 @@
|
||||
<div class="layui-row layui-col-space10">
|
||||
<div class="layui-col-lg12 layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="card-block">
|
||||
<div id="week-container" style="height:350px"></div>
|
||||
<div class="layui-card-header">
|
||||
<a id="weekTab" class="my-tab-item my-tab-item-select">周流量趋势</a>
|
||||
<a id="dayTab" class="my-tab-item">天流量趋势</a>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div id="week-container" tabId="weekTab" class="my-tab-content"></div>
|
||||
<div id="date-container" tabId="dayTab" class="my-tab-content" style="display: none"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -105,75 +125,114 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.use(['admin'], function () {
|
||||
layui.use(['admin', "echarts"], function () {
|
||||
let admin = layui.admin;
|
||||
let echarts = layui.echarts;
|
||||
let statData;
|
||||
|
||||
let browserChart = echarts.init(document.getElementById("browser-container"));
|
||||
$(".my-tab-item").click(function() {
|
||||
let selectId = $(this).attr('id');
|
||||
$(".my-tab-item").each(function() {
|
||||
let eachId = $(this).attr('id');
|
||||
if (eachId === selectId) {
|
||||
$(this).addClass("my-tab-item-select");
|
||||
} else {
|
||||
$(this).removeClass("my-tab-item-select");
|
||||
}
|
||||
});
|
||||
$("[tabId]").each(function() {
|
||||
let tabId = $(this).attr('tabId');
|
||||
if (tabId === selectId) {
|
||||
$(this).show();
|
||||
if ($(this).html().length === 0) {
|
||||
showDateChart($(this).attr('id'));
|
||||
}
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let showDateChart = function (contetnId) {
|
||||
let dateChart = echarts.init(document.getElementById(contetnId), layui.echartsTheme);
|
||||
dateChart.setOption({
|
||||
tooltip: {trigger: "axis"},
|
||||
legend: {
|
||||
data: ['访问量(PV)', '独立用户(UV)']
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: !1,
|
||||
data: statData.statDate_items
|
||||
}
|
||||
],
|
||||
yAxis: [{type: "value"}],
|
||||
series: [
|
||||
{
|
||||
name: '访问量(PV)',
|
||||
type: 'line',
|
||||
smooth: !0,
|
||||
itemStyle: {normal: {areaStyle: {type: "default"}}},
|
||||
data: statData.statDate_pv
|
||||
},
|
||||
{
|
||||
name: '独立用户(UV)',
|
||||
type: 'line',
|
||||
smooth: !0,
|
||||
itemStyle: {normal: {areaStyle: {type: "default"}}},
|
||||
data: statData.statDate_uv
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
let browserChart = echarts.init(document.getElementById("browser-container"), layui.echartsTheme);
|
||||
browserChart.setOption({
|
||||
title : {
|
||||
text: '浏览器分布',
|
||||
subtext: '',
|
||||
x:'center'
|
||||
},
|
||||
tooltip : {
|
||||
trigger: 'item',
|
||||
formatter: "{a} <br/>{b} : {c} ({d}%)"
|
||||
},
|
||||
tooltip: {trigger: "item", formatter: "{a} <br/>{b} : {c} ({d}%)"},
|
||||
legend: {},
|
||||
series : []
|
||||
});
|
||||
browserChart.showLoading();
|
||||
|
||||
let osChart = echarts.init(document.getElementById("operatingSystem-container"));
|
||||
let osChart = echarts.init(document.getElementById("operatingSystem-container"), layui.echartsTheme);
|
||||
osChart.setOption({
|
||||
title : {
|
||||
text: '系统分布',
|
||||
subtext: '',
|
||||
x:'center'
|
||||
},
|
||||
tooltip : {
|
||||
trigger: 'item',
|
||||
formatter: "{a} <br/>{b} : {c} ({d}%)"
|
||||
},
|
||||
tooltip: {trigger: "item", formatter: "{a} <br/>{b} : {c} ({d}%)"},
|
||||
legend: {},
|
||||
series : []
|
||||
});
|
||||
osChart.showLoading();
|
||||
|
||||
let weekChart = echarts.init(document.getElementById("week-container"));
|
||||
let weekChart = echarts.init(document.getElementById("week-container"), layui.echartsTheme);
|
||||
weekChart.setOption({
|
||||
title: {
|
||||
text: '流量趋势'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
label: {
|
||||
backgroundColor: '#6a7985'
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {trigger: "axis"},
|
||||
legend: {
|
||||
data: ['访问量(PV)', '独立用户(UV)']
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
boundaryGap: !1,
|
||||
data: []
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
yAxis: [{type: "value"}],
|
||||
series: []
|
||||
});
|
||||
weekChart.showLoading();
|
||||
|
||||
admin.req('api-log/requestStat', {}, function (data) {
|
||||
statData = data;
|
||||
$('#pv').html(data.currDate_pv);
|
||||
$('#uv').html(data.currDate_uv);
|
||||
$('#weekPv').html(data.currWeek_pv);
|
||||
@@ -184,23 +243,16 @@
|
||||
browserChart.setOption({
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
x: 'left',
|
||||
data: data.browser_legendData
|
||||
},
|
||||
series : [
|
||||
{
|
||||
name: '浏览器',
|
||||
name: '访问来源',
|
||||
type: 'pie',
|
||||
radius : '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: data.browser_datas,
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
center: ['60%', '60%'],
|
||||
data: data.browser_datas
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -209,7 +261,7 @@
|
||||
osChart.setOption({
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
x: 'left',
|
||||
data: data.operatingSystem_legendData
|
||||
},
|
||||
series : [
|
||||
@@ -217,15 +269,8 @@
|
||||
name: '操作系统',
|
||||
type: 'pie',
|
||||
radius : '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: data.operatingSystem_datas,
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
center: ['60%', '60%'],
|
||||
data: data.operatingSystem_datas
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -235,7 +280,7 @@
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
boundaryGap: !1,
|
||||
data: data.statWeek_items
|
||||
}
|
||||
],
|
||||
@@ -243,19 +288,15 @@
|
||||
{
|
||||
name: '访问量(PV)',
|
||||
type: 'line',
|
||||
areaStyle: {},
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'top'
|
||||
}
|
||||
},
|
||||
smooth: !0,
|
||||
itemStyle: {normal: {areaStyle: {type: "default"}}},
|
||||
data: data.statWeek_pv
|
||||
},
|
||||
{
|
||||
name: '独立用户(UV)',
|
||||
type: 'line',
|
||||
areaStyle: {},
|
||||
smooth: !0,
|
||||
itemStyle: {normal: {areaStyle: {type: "default"}}},
|
||||
data: data.statWeek_uv
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user