ke_junjie
2025-06-04 bb6e2230bb8ded3c5546bc4e4c282ee343754475
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
<template>
  <div class="chart-wrapper" ref="outputline"></div>
</template>
 
<script>
import resize from '@/mixins/resize';
const echarts = require('echarts');
export default {
  name: 'placePie',
  props: {
    titleechart: {
      type: String,
      default: ''
    },
    linelist: {
      type: Object,
      default: () => {}
    },
    colorList: {
      type: Array,
      default: () => []
    },
    colors: {
      type: String,
      default: '#636972'
    }
  },
  mixins: [resize],
  data() {
    return {};
  },
  mounted() {
    this.initEchart();
  },
  methods: {
    initEchart() {
      let serieslist = [];
 
      let data = this.linelist.data;
      if (data) {
        data.forEach((item, index) => {
          serieslist.push({
            name: item.name,
            type: 'bar',
            smooth: true,
            data: item.xdata,
            // 修改的是线的颜色
            lineStyle: {
              width: 10
            }
          });
        });
      }
 
      this.myChart = echarts.init(this.$refs.outputline);
      this.myChart.setOption(
        {
          title: {
            text: this.linelist && this.linelist.data ? this.titleechart : '暂无数据',
 
            textStyle: {
              color: this.colors,
              fontWeight: 'normal',
              fontSize: 50
            },
 
            left: '45%',
            x: 'center',
            y: 0,
            itemGap: 10
          },
 
          tooltip: {
            //提示框组件
            trigger: 'axis',
            // formatter: '{b0}: {c0}<br />{b1}: {c1}',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 36
            }
          },
          grid: {
            left: '1%',
            right: '1%',
            bottom: '1%',
            top: '27%',
            //    padding:'0 0 10 0',
            containLabel: true
          },
          legend: {
            //图例组件,颜色和名字
            right: '1%',
            top: '15%',
            itemGap: 16,
            itemWidth: 18,
            itemHeight: 10,
            data: this.linelist.legend,
            textStyle: {
              fontStyle: 'normal',
              fontFamily: '微软雅黑',
              color: this.colors,
              fontSize: 28
            }
          },
          xAxis: [
            {
              type: 'category',
              //    boundaryGap: true,//坐标轴两边留白
              data: this.linelist.xdata,
              // data: Axdata,
              axisLabel: {
                interval: 0, //设置为 1,表示『隔一个标签显示一个标签』
                margin: 10,
                textStyle: {
                  fontSize: 28
                }
              },
              axisLine: { show: true, lineStyle: { color: this.colors, width: 10 } },
              splitLine: {
                show: false,
                lineStyle: { color: this.colors, width: 10 }
              },
              axisTick: {
                show: false
              }
            }
          ],
          yAxis: [
            {
              type: 'value',
              splitNumber: 5,
              axisLabel: {
                textStyle: {
                  fontSize: 36
                }
              },
              axisLine: {
                lineStyle: {
                  color: this.colors,
                  width: 10
                }
              },
              axisTick: {
                show: false
              },
              splitLine: {
                show: true,
                lineStyle: {
                  color: this.colors,
                  width: 10
                }
              }
            }
          ],
          dataZoom: [
            {
              type: 'inside',
              startValue: 10,
              endValue: 15
            }
          ],
          series: serieslist
        },
        true
      );
    }
  },
  watch: {
    linelist: {
      handler() {
        this.initEchart();
      },
      deep: true
    }
  }
};
</script>