longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
<template>
  <div class="gauge-chart-label">
    <div class="gauge-chart-label-content">
      <gauge-chart
        ref="chart"
        :line-color="lineColor"
        :left-colors="leftColors"
        :right-colors="rightColors"
        :unit="unit"
      ></gauge-chart>
    </div>
    <div class="gauge-chart-label-footer">
      <div class="radius-box">{{ label }}</div>
    </div>
  </div>
</template>
 
<script>
import GaugeChart from "@/components/chart/gauge-chart.vue";
import LabelBox from "./label-box.vue";
export default {
  props: {
    lineColor: {
      type: String,
      default: "#ff4887",
    },
    leftColors: {
      type: Array,
      default() {
        return ["#ff4b8750", "#ff4b8750"];
      },
    },
    rightColors: {
      type: Array,
      default() {
        return ["#ff4b87", "#ff84b6"];
      },
    },
    label: {
      type: String,
      default: "文本",
    },
    unit: {
      type: String,
      default: "A",
    },
    value: {
      type: Number,
      default: 0,
    },
  },
  components: {
    GaugeChart,
    LabelBox,
  },
  data() {
    return {};
  },
  watch: {
    value(n) {
      this.setData(n);
    },
  },
  methods: {
    setData(data) {
      this.$refs.chart.setData(data);
    },
    resize() {
      this.$refs.chart.resize();
    },
  },
  mounted() {
    let value = this.value;
    this.setData(value);
  },
};
</script>
 
<style scoped>
.gauge-chart-label {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
}
.gauge-chart-label-content {
  flex: 1;
  width: 100%;
}
.gauge-chart-label-footer {
  padding: 8px 0;
}
.radius-box {
  display: inline-block;
  font-size: 14px;
  padding: 4px 32px;
  border-radius: 16px;
  border: 1px solid #00ffef;
}
</style>