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);
    }
相关推荐
爱勇宝40 分钟前
深扒 Anthropic 1680 位工程师简历:应届生几乎没机会,AI 公司最缺的不是博士
前端·后端·程序员
kyriewen1 小时前
同事每天催我 Code Review,我写了个脚本让 AI 替我 review PR——现在他反过来催 AI 了
前端·javascript·ai编程
user20585561518133 小时前
Windows 项目安装时报 `node-sass` 错误,如何快速处理
前端
LiaCode3 小时前
Redis 在生产项目的使用
前端·后端
LiaCode4 小时前
一天学完 redis 的爽翻版核心知识总结
前端·后端
大刚测试开发实战4 小时前
如何内网穿透访问本地私有化部署的TestHub
前端·后端·github
风骏时光牛马4 小时前
# Ruby基于Rails框架实现多角色权限管理与数据分页查询完整实战代码案例
前端
weedsfly4 小时前
迭代器、生成器与异步迭代——让数据“按需流动”的艺术
前端·javascript
xiaodaoluanzha4 小时前
迄今為止,最簡單的編程語言 Nolang
前端·后端
Csvn4 小时前
Fetch 请求竞态终结者:AbortController 不只是用来"取消"的
前端