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
 
<template>
    <div class="echarts-box" id="floodLineChart">
 
    </div>
</template>
 
<script>
export default {
    data () {
        return {
            myChart: null
        }
    },
 
    mounted () {
        let stackBarData = {
            xAxisData: ["4-1", "4-2", "4-3", "4-4", "4-5", "4-6", "4-7", "4-8"],
            seriesData_01: ["20", "30", "15", "14", "10", "8", "5", "18"],
            seriesData_02: ["12", "16", "10", "8", "6", "4", "3", "13"],
            seriesData_03: ["6", "10", "3", "4", "3", "3", "1", "4"],
            seriesData_04: ["2", "4", "2", "2", "1", "1", "1", "1"]
        }
    },
    destroyed () {
 
    },
    methods: {
        initEcharts (params) {
            this.$nextTick(() => {
                this.createStackBarChart(params)
            })
        },
 
        createStackBarChart (chartData) {
            if (!this.myChart) {
                this.myChart = this.$echarts.init(
                    document.getElementById('floodLineChart')
                )
            }
 
            // 指定图表的配置项和数据
            var option = {
                legend: {
                    show: true,
                    top: 5,
                    itemWidth: 8,
                    itemHeight: 8,
                    itemGap: 20,
                    left: "center",
                    textStyle: {
                        color: "#B5C5D4",
                        fontSize: 14,
                    },
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "shadow"
                    },
                    formatter: function (e) {
                        if (e.length > 0) {
                            var t = "".concat(e[0].name + " <br/>")
                            e.forEach((item) => {
                                t += item.marker + item.seriesName + ": " + item.value + " 座 <br/>"
                            })
                            return t
                        }
                    }
                },
                xAxis: {
                    data: chartData.xAxisData,
                    name: "",
                    axisLine: {
                        onZero: true,
                        lineStyle: {
                            color: "rgba(186, 198, 208, .4)",
                        },
                    },
                    axisTick: {
                        show: false,
                    },
                    axisLabel: {
                        rotate: 30,
                        interval: 10,
                        fontSize: 10,
                        color: "#B5C5D4",
                    },
                },
                yAxis: {
                    name: '座',
                    minInterval: 1,
                    axisLabel: {
                        fontSize: 10,
                        color: "#B5C5D4",
                    },
                    nameTextStyle: {
                        fontSize: 14,
                        color: "#B5C5D4",
                    },
                    splitLine: {
                        lineStyle: {
                            color: ["#344B64"],
                            type: "dashed",
                            width: 2,
                        },
                    },
                },
                grid: {
                    left: 20,
                    right: 15,
                    top: 40,
                    bottom: 7,
                    containLabel: true,
                },
                series: [
                    {
                        name: "总数",
                        type: "line",
                        data: chartData.seriesData_01,
                        symbol: 'none',
                        lineStyle: {
                            color: '#6152C7'
                        }
                    },
                    {
                        name: "小型",
                        type: "line",
                        symbol: 'none',
                        data: chartData.seriesData_02,
                        lineStyle: {
                            color: '#81E79C'
                        }
                    },
                    {
                        name: "中型",
                        type: "line",
                        symbol: 'none',
                        data: chartData.seriesData_03,
                        lineStyle: {
                            color: '#1C73C3'
                        }
                    },
                    {
                        name: "大型",
                        type: "line",
                        symbol: 'none',
                        data: chartData.seriesData_04,
                        lineStyle: {
                            color: '#F4B34E'
                        }
                    },
                ],
            }
 
            this.myChart.setOption(option)
        },
 
    },
}
</script>
 
<style lang="scss" scoped>
.echarts-box {
    width: 100%;
    height: 220px;
}
</style>