春风项目四线(合箱线、总装线)
wujian
2024-01-25 c6e06980cccbb86fa224633d3585f9164295bff1
提交 | 用户 | 时间
fd2207 1 <template>
2   <div :class="className" :style="{height:height,width:width}" />
3 </template>
4
5 <script>
6 import * as echarts from 'echarts'
7 require('echarts/theme/macarons') // echarts theme
8 import resize from './mixins/resize'
c6e069 9 import { getTopProcess } from "@/api/main/da/passingStationCollection/passingStationCollection";
fd2207 10
11 export default {
12   mixins: [resize],
13   props: {
14     className: {
15       type: String,
16       default: 'chart'
17     },
18     width: {
19       type: String,
20       default: '100%'
21     },
22     height: {
23       type: String,
8adcec 24       default: '350px'
fd2207 25     }
26   },
27   data() {
28     return {
c6e069 29       chart: null,
W 30       data: [],
31       title:[],
fd2207 32     }
33   },
34   mounted() {
c6e069 35     this.getData()
W 36
fd2207 37   },
38   beforeDestroy() {
39     if (!this.chart) {
40       return
41     }
42     this.chart.dispose()
43     this.chart = null
44   },
45   methods: {
c6e069 46     getData(){
W 47       getTopProcess().then(res => {
48         if (res.code === 200){
49           this.data = res.rows
50           this.data.forEach(x => {
51             this.title.push(x.name)
52           })
53           this.$nextTick(() => {
54             this.initChart()
55           })
56         }
57       })
58     },
fd2207 59     initChart() {
60       this.chart = echarts.init(this.$el, 'macarons')
61
62       this.chart.setOption({
e211c9 63         title: {
J 64           text: '工位堵塞Top5', // 标题文本
65           left: 'center' // 标题位置
66         },
fd2207 67         tooltip: {
68           trigger: 'item',
69           formatter: '{a} <br/>{b} : {c} ({d}%)'
70         },
e211c9 71         // textStyle
fd2207 72         legend: {
e211c9 73           orient: 'vertical',
J 74
75           left: 'left',
76           // left: 'center',
77           // bottom: '10',//左侧高度
c6e069 78           data: this.title
fd2207 79         },
80         series: [
81           {
82             name: 'WEEKLY WRITE ARTICLES',
83             type: 'pie',
e211c9 84             // roseType: 'radius',//更改样式
J 85             radius: '50%',
86             // labelLine: {
87             //   length: 10 // 调整标签线的长度
88             // },
89             center: ['50%', '60%'],
c6e069 90             data: this.data,
e211c9 91             label: {
J 92               formatter: '{b}: {c} ({d}%)'
93             },
fd2207 94             animationEasing: 'cubicInOut',
95             animationDuration: 2600
96           }
97         ]
98       })
99     }
100   }
101 }
102 </script>