jxdnsong
2022-10-25 bf5ba56e8a82f0ef699f2eae413d0dc2c4e4f67d
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
<template>
    <div class="container">
        <div class="chart" ref="PipeNet_ref"></div>
    </div>
</template>
 
<script>
export default {
    data () {
        return {
            chartInstance: null,
            data: [
                {
                    pipe: '给水',
                    long: 530
                },
                {
                    pipe: '雨水',
                    long: 640
                },
                {
                    pipe: '污水',
                    long: 420
                },
                {
                    pipe: '供电',
                    long: 750
                },
                {
                    pipe: '路灯',
                    long: 600
                },
                {
                    pipe: '燃气',
                    long: 500
                },
 
            ]
        }
    },
    mounted () {
        this.initChart()
        this.updateChart()
    },
    methods: {
        initChart () {
            this.chartInstance = this.$echarts.init(this.$refs.PipeNet_ref)
        },
        getData () {
 
        },
        updateChart () {
            const that = this
 
            const pipe = this.data.map((item) => {
                return item.pipe
            })
            const long = this.data.map(item => {
                return item.long
            })
            const option = {
                title: {
                    show: true,
                    text: ['{a|▎}', '{b|管网统计}'],
                    left: 16,
                    top: 6,
                    textStyle: {
                        rich: {
                            a: {
                                color: '#28f2ff',
                                fontSize: 16,
                                weight: 400
                            },
                            b: {
                                color: '#fff',
                                fontSize: 16,
                                weight: 400
                            }
                        }
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    top: '23%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    data: pipe,
                    axisLabel: {
                        color: '#E9F2F3',
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#206489'
                        }
                    },
 
                },
                yAxis: {
                    type: 'value',
                    name: '单位:KM',
                    nameTextStyle: {
                        color: "#fff",
                        padding: [2, 0, 0, -10]
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#206489'
                        }
                    },
                    axisLabel: {
                        color: '#E9F2F3'
                    },
                    splitLine: {
                        lineStyle: {
                            color: '#072651'
                        }
                    }
 
                },
                series: [
                    {
                        name: '管网长度',
                        type: 'bar',
                        data: long,
                        barWidth: '16px',
                        itemStyle: {
                            normal: {
                                // color: this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                                //     offset: 0,
                                //     color: '#001541'
                                // }, {
                                //     offset: 1,
                                //     color: '#28F2FF'
                                // }]),
                            }
                        },
                    }
                ]
            }
 
            this.chartInstance.setOption(option)
        }
    }
}
</script>
 
<style lang="scss" scoped>
.container {
    width: 400px;
    height: 100%;
    background: url(/zhjg/img/home/juxing2.png) no-repeat;
    background-size: 100% 100%;
 
    .chart {
        width: 100%;
        height: 100%;
    }
}
</style>