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
101
102
103
104
105
106
<template>
  <div class="progress-block">
    <div class="progress-block-content">
      <progress-block-bar
        ref="chart"
        :max="max"
        :bar-width="barWidth"
        :bar-color="barColor"
        :bg-color="bgColor"
        :font-color="fontColor"
      ></progress-block-bar>
    </div>
    <div class="progress-block-footer">
      <label-box :value="value" :unit="unit"></label-box>
    </div>
  </div>
</template>
 
<script>
import progressBlockBar from "@/components/chart/progress-block-bar";
import labelBox from "@/pages/dataTest/components/label-box";
export default {
  components: {
    progressBlockBar,
    labelBox,
  },
  props: {
    barWidth: {
      type: Number,
      default: 24,
    },
    barColor: {
      type: String,
      default: "#00feff",
    },
    bgColor: {
      type: String,
      default: "#0b388a",
    },
    fontColor: {
      type: String,
      default: "#fff",
    },
    title: {
      type: String,
      default: "测试",
    },
    value: {
      type: Number,
      default: 0,
    },
    max: {
      type: Number,
      default: 400,
    },
    unit: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  watch: {
    value() {
      this.setChart();
    },
  },
  methods: {
    getData() {
      return [
        {
          name: this.title,
          value: this.value,
        },
      ];
    },
    setChart() {
      let data = this.getData();
      this.$refs.chart.setData(data);
    },
    resize() {
      this.$refs.chart.resize();
    },
  },
  mounted() {
    this.setChart();
  },
};
</script>
 
<style scoped>
.progress-block {
  display: flex;
  justify-items: center;
  align-items: center; /*y轴对滴方式*/
  height: 100px;
}
.progress-block-content {
  flex: 1;
  height: 100%;
}
.progress-block-footer {
  padding: 0 16px;
}
</style>