echarts环形图自定义

echarts环形图自定义,光圈是图片自定义在终点

c 复制代码
  getCXQCharts(valNum, chartId, colorType) {
      const imgUrl =
        colorType === "red"
          ? require("@/assets/images/chrat_icon1.png")
          : require("@/assets/images/chrat_icon.png");
      this[chartId] = this.$echarts.init(document.getElementById(chartId));
      let color1 = colorType === "red" ? "#ae9600" : "#005fae";
      let color2 = colorType === "red" ? "#faa81b" : "#14c9fa";
      let color3 = colorType === "red" ? "#756b05" : "#053d75";

      let option = {
        title: {
          text: "{a|" + valNum + "}{b|%}",
          x: "center",
          y: "center",
          textStyle: {
            rich: {
              a: {
                fontSize: 44,
                fontWeight: "bold",
                color: "#fff",
                fontFamily: "DINPro",
              },
              b: {
                fontSize: 22,
                color: "#fff",
                fontFamily: "Source Han Sans CN",
              },
            },
          },
        },
        series: [
          {
            type: "pie",
            clockWise: false,
            radius: [57, 67], // 缩小饼图预留空间
            startAngle: 90,
            hoverAnimation: false,
            center: ["50%", "50%"],
            data: [
              {
                value: valNum,
                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      0,
                      0,
                      1,
                      [
                        { offset: 0, color: color1 },
                        { offset: 1, color: color2 },
                      ]
                    ),
                  },
                },
              },
              {
                //画中间的图标
                name: "",
                value: 0,
                offset: [-8, -18], // [-8向左偏移, -8向上偏移]
                label: {
                  position: "inside",
                  backgroundColor: {
                    image: imgUrl,
                  },
                  width: 28,
                  height: 28,
                
                },
              },
              {
                value: 100 - valNum,
                name: "invisible",
                itemStyle: {
                  normal: { color: color3 },
                  emphasis: { color: color3 },
                },
              },
            ],
          },
        ],
      };

      this[chartId].setOption(option, true);
    }
相关推荐
ZC跨境爬虫1 小时前
跟着 MDN 学 HTML day_28:(使用选择器 API 在 DOM 树中进行选择与遍历)
前端·ui·html·音视频·webrtc
东北甜妹1 小时前
K8s Ingress
java·运维·前端
RickyWasYoung1 小时前
【Matlab】合并多个子图的fig文件为一个大图
前端·matlab·信息可视化
爱滑雪的码农1 小时前
React+three.js之项目搭建
前端·javascript·react.js
Front思1 小时前
安卓证书申请 + iOS 证书申请(含 Windows 无 Mac 方案)+ HBuilderX 云打包配置
android·macos·ios
ii_best1 小时前
ios/安卓脚本工具开发按键精灵脚本常见运行时错误与解决方法
android·ios·自动化
张风捷特烈1 小时前
状态管理大乱斗#07 | Signals 源码评析 - 暗流涌动
android·前端·flutter
接着奏乐接着舞3 小时前
sse 两种调用方式
前端·javascript·vue.js
不会敲代码19 小时前
手写 Mini React:从 JSX 到虚拟 DOM 再到 render,搞懂 React 底层原理
前端·javascript·react.js