yyt
2024-06-26 572f63fab7f868f3fc5037c4dc7c46e397511597
提交 | 用户 | 时间
0cceb6 1 <template>
Y 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'
9 import { getTopProcess } from "@/api/main/da/passingStationCollection/passingStationCollection";
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,
24       default: '350px'
25     }
26   },
27   data() {
28     return {
29       chart: null,
30       data: [],
31       title:[],
32     }
33   },
34   mounted() {
35     this.getData()
36
37   },
38   beforeDestroy() {
39     if (!this.chart) {
40       return
41     }
42     this.chart.dispose()
43     this.chart = null
44   },
45   methods: {
46     getData(){
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     },
59     initChart() {
60       this.chart = echarts.init(this.$el, 'macarons')
61
62       this.chart.setOption({
63         title: {
64           text: '工位堵塞Top5', // 标题文本
65           left: 'center' // 标题位置
66         },
67         tooltip: {
68           trigger: 'item',
69           formatter: '{a} <br/>{b} : {c} ({d}%)'
70         },
71         // textStyle
72         legend: {
73           orient: 'vertical',
74
75           left: 'left',
76           // left: 'center',
77           // bottom: '10',//左侧高度
78           data: this.title
79         },
80         series: [
81           {
82             name: 'WEEKLY WRITE ARTICLES',
83             type: 'pie',
84             // roseType: 'radius',//更改样式
85             radius: '50%',
86             // labelLine: {
87             //   length: 10 // 调整标签线的长度
88             // },
89             center: ['50%', '60%'],
90             data: this.data,
91             label: {
92               formatter: '{b}: {c} ({d}%)'
93             },
94             animationEasing: 'cubicInOut',
95             animationDuration: 2600
96           }
97         ]
98       })
99     }
100   }
101 }
102 </script>