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
| <!--
| * @Author: shuishen 1109946754@qq.com
| * @Date: 2023-04-04 13:42:12
| * @LastEditors: shuishen 1109946754@qq.com
| * @LastEditTime: 2023-04-04 13:52:31
| * @FilePath: \hbsl\src\views\home\components\pieEcharts.vue
| * @Description:
| *
| * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
| -->
| <template>
| <div class="echarts-box" id="BarEcharts">
|
| </div>
| </template>
|
| <script>
| export default {
| data() {
| return {}
| },
|
| mounted() {
| this.$nextTick(() => {
| this.initEcharts()
| })
| },
|
| methods: {
| initEcharts() {
| const that = this //注意,要将this进行指代,否则在click里面this指向发生了改变
| const myChart = this.$echarts.init(document.getElementById('BarEcharts'))
| let xAxisData = ['武汉市','黄石市','十堰市','宜昌市','襄阳市','鄂州市','荆门市','孝感市'];
| let data1 = ['20','30','15','1','10','8','5','18'];
| let data2 = ['2','6','5','10','10','8','5','1'];
| let data3 = ['3','5','1','10','3','9','15','1'];
| var emphasisStyle = {
| itemStyle: {
| shadowBlur: 10,
| shadowColor: 'rgba(0,0,0,0.3)'
| }
| };
| // 指定图表的配置项和数据
| var option = {
| legend: {
| data: ['大型', '中型', '小型'],
| left: '10%'
| },
| tooltip: {},
| xAxis: {
| data: xAxisData,
| name: '',
| axisLine: {onZero: true},
| splitLine: {show: false},
| splitArea: {show: false}
| },
| yAxis: {
| name: '数量',
| },
| grid: {
| bottom: 100
| },
| series: [
| {
| name: '大型',
| type: 'bar',
| stack: 'one',
| emphasis: emphasisStyle,
| data: data1
| },
| {
| name: '中型',
| type: 'bar',
| stack: 'one',
| emphasis: emphasisStyle,
| data: data2
| },
| {
| name: '小型',
| type: 'bar',
| stack: 'one',
| emphasis: emphasisStyle,
| data: data3
| }
| ]
| };
|
| myChart.setOption(option)
| },
|
| },
| }
| </script>
|
| <style lang="scss" scoped>
| .echarts-box {
| width: 100%;
| height: 100%;
| }
| </style>
|
|