选煤厂生产管理平台前端代码
dongyukun
2024-12-10 5cc1d92af645c2f8f4f6d1d3777283b70df78ccd
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
 
<template>
  <div>
 
    <div id="histogram" ref="histogram"></div>
  </div>
</template>
<script>
      export default {
        name: 'EchartTimelineHistogramdet',
        data() {
          return {
            HdataMap:{
              legendData:[],
              xAxisData:[],
              yAxisData:[], //{item: '2022-06-05' value:[1,2,3]}
              items:[],
               colorData:[],
               bl:"",
            colorSrcData:{},
            },
            machart:null,
          };
        },
         props:{
          dataMap:{
            type: Object,
            default:{}
          }
        },
       watch: {
          dataMap(newVal, oldVal){
          this.HdataMap = newVal
          this.changetype()
          }
        },
        methods: {
          changetype() {
 
                var seriesOption=[]
                var optionType = 'bar'
                var pieData=[]
 
               if(Object.keys(this.HdataMap).length===0 ||!this.HdataMap.yAxisData||!this.HdataMap.items||this.HdataMap.yAxisData.length===0 ||this.HdataMap.items.length===0){
                    this.machart.setOption({},true)
                  return
             }
             var barWidth = this.HdataMap.legendData.length<=9?'6%' :''
 
                   for (var itemIndex=0;itemIndex<=this.HdataMap.items.length-1;itemIndex++){
                        var seriesData=[]
                        pieData=[]
                      for(var kLegend in this.HdataMap.legendData){
 
                        seriesData.push({
                           type:'bar',
                           barWidth: barWidth,
                            data: [this.HdataMap.yAxisData[itemIndex].value[kLegend]],
                            name:this.HdataMap.legendData[kLegend],
                            label: {
                            show : true,
                            position:'top',
                            fontSize:12,
                            color:'black'
                            },
                        })
                        pieData.push({
                          value:this.HdataMap.yAxisData[itemIndex].value[kLegend],name:this.HdataMap.legendData[kLegend]
                        })
                      }
                      seriesData.push({
                        type: 'pie',
                        center: ['85%', '23%'],
                        radius: '23%',
                        data: pieData
                      })
                    seriesOption.push({
                        title: {
                        text: this.HdataMap.bl?this.HdataMap.yAxisData[itemIndex].item+this.HdataMap.bl:'',
                        textStyle:{
                        fontSize:18
                        }
                        },
                        xAxis: [
                        {
                        axisTick: {
                        alignWithLabel: true
                        },
                        type: "category",
                        data : ['']
                        },
                        ],
                        yAxis: {
                        type: 'value',
                       },
                        color:this.HdataMap.colorData,
                        series: seriesData
                    })
                   }
               const option = {
                baseOption: {
                timeline: {
                axisType: 'category',
                show: true,
                autoPlay: true,
                playInterval: 1500,
                data: this.HdataMap.items,
                currentIndex:0
                },
                grid: { containLabel: true ,top:80},
                xAxis: [{
                type: 'category',
                data:['']
                }],
                legend: {
                  icon: "roundRect",
                orient: 'horizontal',
                x:'right',
                y: "top",
                right:"left",
                top:"20",
                bottom:"100",
                data: this.HdataMap.legendData
                },
                tooltip: {}
                },
                options:seriesOption
               }
              this.machart.setOption(option,true)
              },
 
 
 
        },
        mounted() {
           this.machart =this.$echarts.init(this.$refs.histogram);
          window.addEventListener("resize",  ()=> {
                  this.machart.resize();
                })
 
        },
      }
 </script>
  <style lang="scss" scoped>
 
#histogram {
  max-height: 700px;
  // max-height: 400px;
  height: 700px;
  margin-top:40px
}
</style>