1
Surpriseplus
2022-11-18 bd6d4e1c5cefef5355afe5f84e09eeb23da94ffd
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
113
114
115
116
117
118
119
120
121
122
<template>
  <div class="echart25_box">
    <div id="echart25"></div>
  </div>
</template>
 
<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {};
  },
  mounted() {
    this.lineChart();
  },
  //方法集合
  methods: {
    lineChart() {
      let option = {
        title: {
          text: "用户增量和总量占比",
          textStyle: {
            color: "#fff",
          },
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
        },
        graphic: [
          {
            type: "text",
            left: "center",
            top: "40%",
            style: {
              fill: "#fff",
              text: "总用户量",
            },
          },
          {
            type: "text",
            left: "center",
            top: "50%",
            z: 10,
            style: {
              fill: "#fff",
 
              text: "400",
              font: "30px Microsoft YaHei",
            },
          },
        ],
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          // containLabel: true,
        },
        series: [
          {
            name: "用户量",
            type: "pie",
            radius: ["40%", "70%"],
            labelLine: {
              normal: {
                length: 15, // 指示线宽度
                lineStyle: {
                  color: "#fff", // 指示线颜色
                },
              },
            },
            label: {
              normal: {
                // 各分区的提示内容
                // params: 即下面传入的data数组,通过自定义函数,展示你想要的内容和格式
                formatter: function (params) {
                  return params.name + "\n\n" + params.percent + "%";
                },
                textStyle: {
                  // 提示文字的样式
                  color: "#fff",
                  fontSize: 14,
                },
              },
            },
            data: [
              { value: 280, name: "往年用户量" },
              { value: 120, name: "今年新增用户量" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      let myChart = this.$echarts.init(document.getElementById("echart25"));
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
  },
  created() {},
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.echart25_box {
  padding: 20px;
  // background: rgba(0, 0, 0, 0.6);
}
#echart25 {
  width: 100%;
  height: 100%;
}
</style>