uv-trend.vue
3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
<Card>
<div slot="title">
流量趋势
</div>
<div class="overview-type" slot="extra">
<client-type v-model="type"></client-type>
</div>
<div class="uv-chart" style="width:100%;height:400px;"></div>
</Card>
</template>
<script>
import echart from 'common/echart';
import clientType from 'common/client-type';
import * as service from 'service.pc';
import * as _ from 'lodash';
let myChart;
export default {
name: 'uv-trend',
props: ['appEdition'],
data() {
return {
type: 'all'
};
},
watch: {
type: function() {
this.loadData();
},
appEdition: function() {
this.loadData();
}
},
mounted() {
echart.then(chart => {
this.ECharts = chart;
myChart = this.ECharts.init(document.querySelector('.uv-chart'));
this.loadData();
});
},
components: {clientType},
methods: {
loadData: function() {
service.get('data-analysis-web/flowsurvey/trend', {
type: this.type,
appEdition: this.appEdition
}).then(result => {
result = result.data.content;
// 绘制图表
myChart.setOption({
title: {
text: '折线图堆叠'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['访客数', '浏览量', '跳失率', '人均浏览量', '平均停留时长']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: _.map(result,'date')
},
yAxis: {
type: 'value'
},
series: [
{
name: '访客数',
type: 'line',
smooth: true,
stack: '总量',
data: _.map(result,'uv')
},
{
name: '浏览量',
type: 'line',
smooth: true,
stack: '总量',
data: _.map(result,'pv')
},
{
name: '跳失率',
type: 'line',
smooth: true,
stack: '总量',
data: _.map(result,'loss_rate')
},
{
name: '人均浏览量',
type: 'line',
smooth: true,
stack: '总量',
data: _.map(result,'avg_pv')
},
{
name: '平均停留时长',
type: 'line',
smooth: true,
stack: '总量',
data: _.map(result,'avg_stay')
}
]
});
});
}
}
};
</script>
<style lang="scss">
</style>