增加天流量趋势,并优化首页图表样式

This commit is contained in:
zlt
2020-03-11 16:14:56 +08:00
parent bd692901a0
commit 2dcdcfd731
7 changed files with 338 additions and 94 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,82 @@
/** layuiAdmin.std-v2020.1.24 LPPL License By https://www.layui.com/admin/ */
;layui.define(function (e) {
e("echartsTheme", {
color: ["#009688", "#1E9FFF", "#5FB878", "#FFB980", "#D87A80", "#8d98b3", "#e5cf0d", "#97b552", "#95706d", "#dc69aa", "#07a2a4", "#9a7fd1", "#588dd5", "#f5994e", "#c05050", "#59678c", "#c9ab00", "#7eb00a", "#6f5553", "#c14089"],
title: {textStyle: {fontWeight: "normal", color: "#666"}},
dataRange: {itemWidth: 15, color: ["#009688", "#e0ffff"]},
toolbox: {color: ["#1e90ff", "#1e90ff", "#1e90ff", "#1e90ff"], effectiveColor: "#ff4500"},
tooltip: {
backgroundColor: "rgba(50,50,50,0.5)",
axisPointer: {
type: "line",
lineStyle: {color: "#009688"},
crossStyle: {color: "#008acd"},
shadowStyle: {color: "rgba(200,200,200,0.2)"}
}
},
dataZoom: {dataBackgroundColor: "#efefff", fillerColor: "rgba(182,162,222,0.2)", handleColor: "#008acd"},
grid: {borderColor: "#eee"},
categoryAxis: {
axisLine: {lineStyle: {color: "#009688"}},
axisTick: {show: !1},
splitLine: {lineStyle: {color: ["#eee"]}}
},
valueAxis: {
axisLine: {lineStyle: {color: "#009688"}},
splitArea: {show: !0, areaStyle: {color: ["rgba(250,250,250,0.1)", "rgba(200,200,200,0.1)"]}},
splitLine: {lineStyle: {color: ["#eee"]}}
},
polar: {
axisLine: {lineStyle: {color: "#ddd"}},
splitArea: {show: !0, areaStyle: {color: ["rgba(250,250,250,0.2)", "rgba(200,200,200,0.2)"]}},
splitLine: {lineStyle: {color: "#ddd"}}
},
timeline: {
lineStyle: {color: "#009688"},
controlStyle: {normal: {color: "#009688"}, emphasis: {color: "#009688"}},
symbol: "emptyCircle",
symbolSize: 3
},
bar: {itemStyle: {normal: {barBorderRadius: 2}, emphasis: {barBorderRadius: 2}}},
line: {smooth: !0, symbol: "emptyCircle", symbolSize: 3},
k: {
itemStyle: {
normal: {
color: "#d87a80",
color0: "#2ec7c9",
lineStyle: {color: "#d87a80", color0: "#2ec7c9"}
}
}
},
scatter: {symbol: "circle", symbolSize: 4},
radar: {symbol: "emptyCircle", symbolSize: 3},
map: {
itemStyle: {
normal: {areaStyle: {color: "#ddd"}, label: {textStyle: {color: "#d87a80"}}},
emphasis: {areaStyle: {color: "#fe994e"}}
}
},
force: {itemStyle: {normal: {linkStyle: {color: "#1e90ff"}}}},
chord: {
itemStyle: {
normal: {
borderWidth: 1,
borderColor: "rgba(128, 128, 128, 0.5)",
chordStyle: {lineStyle: {color: "rgba(128, 128, 128, 0.5)"}}
},
emphasis: {
borderWidth: 1,
borderColor: "rgba(128, 128, 128, 0.5)",
chordStyle: {lineStyle: {color: "rgba(128, 128, 128, 0.5)"}}
}
}
},
gauge: {
axisLine: {lineStyle: {color: [[.2, "#2ec7c9"], [.8, "#5ab1ef"], [1, "#d87a80"]], width: 10}},
axisTick: {splitNumber: 10, length: 15, lineStyle: {color: "auto"}},
splitLine: {length: 22, lineStyle: {color: "auto"}},
pointer: {width: 5}
},
textStyle: {fontFamily: "微软雅黑, Arial, Verdana, sans-serif"}
})
});
@@ -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
}
]