feb955a5
liuqimichale
车流量section
|
1
2
3
4
5
6
7
|
<template>
<div :class="className" :style="{height:height,width:width}"></div>
</template>
<script>
import echarts from 'echarts'
|
feb955a5
liuqimichale
车流量section
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import {debounce} from '../utils/debounce'
export default {
name: 'lineChart',
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
|
8a59623c
liuqimichale
进出场
|
23
|
default: '100%'
|
feb955a5
liuqimichale
车流量section
|
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
|
},
autoResize: {
type: Boolean,
default: true
},
chartData: {
type: Object,
required: true
}
},
data() {
return {
chart: null,
sidebarElm: null
}
},
watch: {
chartData: {
deep: true,
}
},
mounted() {
this.initChart()
if (this.autoResize) {
this.__resizeHandler = debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)
window.addEventListener('resize', this.__resizeHandler)
}
},
beforeDestroy() {
if (!this.chart) {
return
}
if (this.autoResize) {
window.removeEventListener('resize', this.__resizeHandler)
}
this.chart.dispose()
this.chart = null
},
methods: {
setOptions({xData, yData} = {}) {
this.chart.setOption({
tooltip: {
trigger: 'axis'
},
|
8a59623c
liuqimichale
进出场
|
73
|
color:['#FFB130','#01AEFE'],
|
feb955a5
liuqimichale
车流量section
|
74
|
legend: {
|
8a59623c
liuqimichale
进出场
|
75
76
77
78
79
|
data:['出场','入场'],
bottom:'2%',
textStyle: {
color: '#59AAF7'
}
|
feb955a5
liuqimichale
车流量section
|
80
81
|
},
grid: {
|
8a59623c
liuqimichale
进出场
|
82
|
top:'8%',
|
feb955a5
liuqimichale
车流量section
|
83
84
|
left: '3%',
right: '4%',
|
8a59623c
liuqimichale
进出场
|
85
|
bottom: '14%',
|
feb955a5
liuqimichale
车流量section
|
86
87
88
89
|
containLabel: true
},
xAxis: {
|
8a59623c
liuqimichale
进出场
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
axisLabel : {
textStyle: {
color: '#fff'
}
},
axisLine:{
lineStyle:{
color:'rgba(89,170,247,.3)'
}
},
axisTick: {
show: false
},
splitLine: {
show: false
},
|
feb955a5
liuqimichale
车流量section
|
106
107
108
|
data: ['周一','周二','周三','周四','周五','周六','周日']
},
yAxis: {
|
8a59623c
liuqimichale
进出场
|
109
110
111
112
113
114
|
type: 'value',
axisLabel : {
formatter: '{value}',
textStyle: {
color: '#fff'
}
|
feb955a5
liuqimichale
车流量section
|
115
|
},
|
8a59623c
liuqimichale
进出场
|
116
117
118
119
|
axisLine:{
lineStyle:{
color:'rgba(89,170,247,.3)'
}
|
feb955a5
liuqimichale
车流量section
|
120
|
},
|
8a59623c
liuqimichale
进出场
|
121
122
123
124
125
|
axisTick: {
show: false
},
splitLine: {
show: false
|
feb955a5
liuqimichale
车流量section
|
126
|
},
|
8a59623c
liuqimichale
进出场
|
127
128
129
|
splitNumber:3
},
series: [
|
feb955a5
liuqimichale
车流量section
|
130
|
{
|
8a59623c
liuqimichale
进出场
|
131
|
name:'出场',
|
feb955a5
liuqimichale
车流量section
|
132
|
type:'line',
|
8a59623c
liuqimichale
进出场
|
133
134
135
136
|
data:[120, 132, 101, 134, 90, 230, 210],
lineStyle: {
color: '#FFB130'
}
|
feb955a5
liuqimichale
车流量section
|
137
138
|
},
{
|
8a59623c
liuqimichale
进出场
|
139
|
name:'入场',
|
feb955a5
liuqimichale
车流量section
|
140
|
type:'line',
|
8a59623c
liuqimichale
进出场
|
141
142
143
144
|
data:[220, 182, 191, 234, 290, 330, 310],
lineStyle: {
color: '#08B9FC'
}
|
feb955a5
liuqimichale
车流量section
|
145
146
147
148
149
150
|
}
]
})
},
initChart() {
|
8a59623c
liuqimichale
进出场
|
151
|
this.chart = echarts.init(this.$el)
|
feb955a5
liuqimichale
车流量section
|
152
153
154
155
156
|
this.setOptions(this.chartData)
}
}
}
</script>
|