hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
<template>
  <div>
    <div id="chart3" class="chart2"></div>
  </div>
</template>
<script>
export default {
  props: {
    detail: {
      type: Object,
      default: (_) => {
        return {};
      },
    },
  },
  components: {},
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.chart();
  },
  methods: {
    chart() {
      var chartDom = document.getElementById("chart3");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        title: {
          text: "",
          subtext: "",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "center",
          top: "bottom",
          formatter: (name) => {
            let text = "";
            if (name === "志愿者活动总时长") {
              text = `志愿者活动总时长${this.detail.participateVolunteerActivityDuration||0}小时 占比${this.detail.participateVolunteerActivityDurationPercent||0}%`;
            } else {
              text = `党员活动总时长${this.detail.participatePartyActivityDuration||0}小时 占比${this.detail.participatePartyActivityDurationPercent||0}%`;
            }
            return text;
          },
        },
        series: [
          {
            name: "参与活动时长",
            type: "pie",
            radius: "50%",
            center: ["50%", "30%"],
            data: [
              {
                value: this.detail.participateVolunteerActivityDuration || 0,
                name: "志愿者活动总时长",
              },
              {
                value: this.detail.participatePartyActivityDuration || 0,
                name: "党员活动总时长",
              },
            ],
            label: {
              show: false,
            },
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
 
      option && myChart.setOption(option);
    },
  },
  watch: {},
  computed: {},
};
</script>
<style scoped>
.chart2 {
  width: 350px;
  height: 350px;
}
</style>