index.vue
1.93 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
<template>
<div id="barChart"></div>
</template>
<script>
export default {
data () {
return {
};
},
mounted () {
this.drawProvinceMap();
},
methods: {
drawProvinceMap () {
var chartDom = document.getElementById('barChart');
var myChart = this.$echarts.init(chartDom);
var option;
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ['网络断开', '网络正常']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'value'
}
],
yAxis: [
{
type: 'category',
axisTick: {
show: false
},
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
}
],
series: [
{
name: '网络正常',
type: 'bar',
itemStyle: {
color: '#67C23A'
},
label: {
show: true,
position: 'inside'
},
emphasis: {
focus: 'series'
},
data: [200, 170, 240, 244, 200, 220, 210]
},
{
name: '网络断开',
type: 'bar',
itemStyle: {
color: '#F56C6C'
},
label: {
show: true,
position: 'inside'
},
emphasis: {
focus: 'series'
},
data: [-120, -132, -101, -134, -190, -230, -210]
}
],
}
myChart.setOption(option);
window.addEventListener("resize", () => {
this.myChart.resize();
});
}
}
}
</script>
<style scoped lang="scss">
#barChart {
width: 100%;
height: 500px;
}
</style>