yangys
2025-11-18 831cfa4c439c6d073d706a82d2a439f8b1818498
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
<!--
 * @Date: 2024-04-18 21:52:18
 * @LastEditors: 李喆(开发组) lzhe@yxqiche.com
 * @LastEditTime: 2025-03-10 14:06:28
 * @FilePath: /cps-web/src/views/mdc/components/StationLiveSpeed.vue
-->
<template>
    <div class="speed">
        <div ref="c" style="width: 30%;height:200px;"></div>
    </div>
</template>
 
<script>
import * as echarts from 'echarts';
export default {
    data() {
        return {
            speedChartName: '主轴负载',
            isspeed: false,
            input: '',
            option: {
                graphic: {
                    type: 'text',
                    enterFrom: {
                        style: { opacity: 0 }// 淡入
                    },
                    enterAnimation: {
                        duration: 1300//动画时长
                    },
                    left: 'center',
                    top: 'bottom',
                    style: {
                        textAlign: 'center',
                        textVerticalAlign: 'middle',
                        fontSize: 12,
                        fontWeight: 'bold',
                        fill: '#333' // 文字颜色
                    }
                },
                series: [
                    {
                        type: 'gauge',
                        axisLine: {
                            lineStyle: {
                                width: 10,
                                color: [
                                    [0.3, '#67e0e3'],
                                    [0.7, '#37a2da'],
                                    [1, '#fd666d']
                                ]
                            }
                        },
                        pointer: {
                            itemStyle: {
                                color: 'auto'
                            }
                        },
                        axisTick: {  //刻度
                            splitNumber: 5,
                            distance: -10,  //刻度与轴线的距离
                            lineStyle: {
                                color: '#fff',
                                width: 2
                            }
                        },
                        splitLine: {
                            distance: -14,  //刻度距离表盘的距离
                            length: 10,
                            lineStyle: {
                                color: '#fff',
                                width: 2  //每个锯齿线宽
                            }
                        },
                        axisLabel: {  //表盘内刻度
                            color: 'inherit',
                            distance: 20,  //刻度距离表盘的距离
                            fontSize: 12
                        },
                        detail: {
                            show: false
                        }
                    }
                ]
            }
        }
    },
    methods: {
        showCharts(a, b, c) {
            var myChartA = echarts.init(this.$refs.c);
            var optionA = JSON.parse(JSON.stringify(this.option));
            optionA.graphic.style.text = [this.speedChartName + a + '%',].join('\n');
            optionA.series[0].data = [{ value: a }];
            myChartA.setOption(optionA);
        }
    },
    mounted() {
        this.showCharts(0, 0, 0);  //调用,三个参数,0-100之间,只传第一个就行
    }
}
</script>
 
<style scoped>
.speed {
    display: flex;
    justify-content: center;
}
 
.speed>div {
    flex: 1;
}
 
</style>