zhongrj
2026-06-02 0299e41c6692684d943b4a206472a86ea84ea4b5
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
<!--
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-05-13 10:48:44
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-05-13 11:59:16
 * @FilePath: \web\bigScreen\src\components\BarEchartsSingle\index.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<template>
    <div class="bar-echarts-box" :id="elementId">
 
    </div>
</template>
 
<script>
export default {
    name: 'BarEchartsSingle',
 
    data () {
        return {
            elementId: ""
        }
    },
 
    created () {
        this.elementId = this.uuid()
    },
 
    mounted () {
        this.$nextTick(() => {
            this.initEcharts()
        })
    },
 
    methods: {
        uuid () {
            return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                var r = Math.random() * 16 | 0,
                    v = c == 'x' ? r : (r & 0x3 | 0x8)
                return v.toString(16)
            })
        },
 
        initEcharts () {
            const that = this
            const myChart = that.$echarts.init(document.getElementById(that.elementId))
 
            const options = {
                color: ['#0EA1DF'],
                tooltip: { //提示框组件
                    trigger: "axis",
                    backgroundColor: '#fff',
                    axisPointer: {
                        type: "shadow",
                        label: {
                            show: false
                        }
                    },
                    textStyle: {
                        color: '#000',
                        fontStyle: 'normal',
                        fontFamily: '微软雅黑',
                        fontSize: 12,
                    }
                },
                grid: {
                    left: '1%',
                    right: '4%',
                    bottom: '6%',
                    top: 30,
                    padding: '0 0 10 0',
                    containLabel: true,
                },
                legend: {//图例组件,颜色和名字
                    right: 10,
                    top: 0,
                    itemGap: 16,
                    itemWidth: 18,
                    itemHeight: 10,
                    data: [{
                        name: '巡查率',
                        //icon:'image://../wwwroot/js/url2.png', //路径
                    }],
                    textStyle: {
                        color: '#a8aab0',
                        fontStyle: 'normal',
                        fontFamily: '微软雅黑',
                        fontSize: 12,
                    }
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: true,//坐标轴两边留白
                        data: ['武汉市', '黄冈市', '黄石市', '随州市', '恩施市'],
                        axisLabel: { //坐标轴刻度标签的相关设置。
                            interval: 0,//设置为 1,表示『隔一个标签显示一个标签』
                            margin: 15,
                            textStyle: {
                                color: '#fff',
                                fontStyle: 'normal',
                                fontFamily: '微软雅黑',
                                fontSize: 12,
                            }
                        },
                        axisTick: {//坐标轴刻度相关设置。
                            show: false,
                        },
                        axisLine: {//坐标轴轴线相关设置
                            lineStyle: {
                                color: '#fff',
                                opacity: 0.2
                            }
                        },
                        splitLine: { //坐标轴在 grid 区域中的分隔线。
                            show: false,
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        splitNumber: 5,
                        max: 100,
                        axisLabel: {
                            formatter: '{value}%',
                            textStyle: {
                                color: '#fff',
                                fontStyle: 'normal',
                                fontFamily: '微软雅黑',
                                fontSize: 12,
                            }
                        },
                        axisLine: {
                            show: false
                        },
                        axisTick: {
                            show: false
                        },
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: ['#fff'],
                                opacity: 0.06
                            }
                        }
 
                    }
                ],
                series: [
                    {
                        name: '巡查率',
                        type: 'bar',
                        data: [20, 56, 10, 12, 16],
                        barWidth: 12,
                        barGap: 0,//柱间距离
                        itemStyle: {//图形样式
                            normal: {
                                barBorderRadius: [6, 6, 0, 0],
                            },
                        },
                    }
                ]
            }
 
            myChart.setOption(options)
        }
    }
}
</script>
 
<style lang="scss" scoped>
.bar-echarts-box {
    width: 100%;
    height: 100%;
}
</style>