index.vue
3.51 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
<template>
<div class="app-WeatherForecast">
<div class="theme-card">
<div class="title"><span>道闸设备</span></div>
<div class="content"><div class="lineChart"></div></div>
</div>
</div>
</template>
<script>
import echarts from 'echarts'
export default {
name: "weatherForecast",
data() {
return {
legendArr: [],
//color: this.$store.state.color,
lineChart: {},
name: '折线图'
}
},
methods: {
createLine(){
// 基于准备好的dom,初始化echarts实例
this.lineChart = echarts.init(document.querySelector('.lineChart'));
const option={
color: ['#325B69', '#698570', '#AE5548', '#6D9EA8', '#9CC2B0', '#C98769'],
grid: {
top: '5%',
left: '2%',
right: '5%',
bottom: '8%',
containLabel: true
},
title: {
show: false
},
tooltip: {
trigger: 'axis',
show:false
},
legend: {
show: false
},
toolbox: {
show: false
},
xAxis: [{
name: '产品',
type: 'category',
axisLine: {
show: false
},
axisTick: {
show: false
},
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.69)'
},
axisLabel: {
textStyle: {
color: 'white'
}
},
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
}],
yAxis: [{
axisLine: {
show: false
},
nameLocation: 'end',
nameGap: 20,
nameRotate: 0,
axisTick: {
show: false
},
splitLine: {
lineStyle: {
color: ['rgba(230, 230, 230, 0.2)']
}
},
axisLabel: {
textStyle: {
color: 'white',
fontSize: 14
}
},
name: '数量',
type: 'value',
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.69)'
}
}],
series: [{
name: '标签3',
type: 'line',
stack: '总量',
data: [50, 32, 21, 14, 20, 30, 40]
}, {
name: '标签4',
type: 'line',
stack: '总量',
data: [30, 32, 31, 34, 30, 30, 20]
}, {
name: '标签5',
type: 'line',
stack: '总量',
data: [20, 32, 1, 34, 20, 13, 10]
}]
};
this.lineChart.setOption(option);
window.addEventListener('resize', function() {
this.lineChart.resize();
console.log("resize");
}.bind(this));
}
},
mounted() {
this.createLine();
}
}
</script>
<style scoped lang="scss">
.app-WeatherForecast {
width: 100%;
.theme-card{
height: 100%;
}
.lineChart{
position: absolute;
margin: 0 auto;
top:0;
bottom: 0;
left:0;
width: 100%;
height: 100%;
}
}
</style>