behaviortrend.vue
4.59 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<template>
<div>
<div class="chart-header-box">
<el-col :span="5" class="header-title">今日事件趋势</el-col>
<div class="search-box">
<!-- <span class="header-label">时间范围</span>
<div class="header-select">
<el-select v-model="illtype">
<el-option
v-for="item in illageList"
:key="item.value"
:label="item.name"
:value="item.code">
</el-option>
</el-select>
</div> -->
<span class="header-label">事件类型</span>
<div class="header-select">
<el-select v-model="illtype" @change="getEventChange">
<el-option
label="全部"
value="">
</el-option>
<el-option
v-for="item in illageList"
:key="item.value"
:label="item.name"
:value="item.code">
</el-option>
</el-select>
</div>
</div>
</div>
<div id="illtrendchart" class="illtrendchart"></div>
</div>
</template>
<script>
export default {
data() {
return {
illtype:'',
illageList: [],
};
},
methods: {
initchart(data) {
console.log(data)
let xdata = [],charData = [];
if(data.length > 0) {
data.map(ele => {
xdata.push(ele.hour)
charData.push(ele.total_num)
})
}
let maychart = this.$echarts.init(document.getElementById("illtrendchart"));
let option = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
}
},
legend: {
data: [""],
align: "right",
bottom: 0,
textStyle: {
color: "#666"
},
itemGap: 30,
itemWidth: 30,
itemHeight: 10
},
grid: {
top:"10%",
left: "3%",
right: "10%",
bottom: "10%",
containLabel: true
},
xAxis: [
{
type: "category",
data: xdata,
axisLine: {
show: true,
lineStyle: {
color: "#D9D9D9",
width: 1,
type: "solid"
}
},
axisTick: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: "#666666",
fontSize: 14
}
}
}
],
yAxis: [
{
type: "value",
splitNumber: 6,
axisLabel: {
formatter: "{value}",
textStyle: {
color: "#666",
fontSize: 14
}
},
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
color: "#D9D9D9",
width:1,
type: "solid"
}
},
splitLine: {
show: true,
lineStyle: {
color: "#E5E5E5",
width: 1,
type: "solid"
}
}
}
],
series: [
{
name: "",
type: "line",
data: charData,
itemStyle: {
normal: {
color: "#0069FF"
}
},
lineStyle: {
normal: {
width: 1,
shadowColor: "rgba(0,0,0,0.4)",
shadowBlur: 10,
shadowOffsetY: 10
}
}
}
]
};
maychart.setOption(option)
},
getEvents(){
this.$api.show.getEventType().then(res => {
this.illageList = res.list_data
})
},
getBehaviorHour(val){
let data ={
eventType:val
}
this.$api.show.getBehaviorHour(data).then(res => {
this.initchart(res.list_data)
})
},
getEventChange(val){
this.getBehaviorHour(val)
}
},
created(){
this.getEvents()
},
mounted() {
this.getBehaviorHour('')
},
};
</script>
<style lang="stylus" scoped>
.chart-header-box{
height 3vh
overflow hidden
font-size 14px
}
.header-title {
line-height 3vh
}
.illtrendchart{
height 22vh
width 30vw
}
.header-label{
font-size 12px
line-height 3vh
float left
}
.header-select{
width 6.5vw
margin .2vh .5vw 0 .2vw
float left
}
.search-box{
float right
}
</style>