echarts 自定义仪表盘设置背景图片

echarts仪表盘 使用插件 vue-echarts

代码示例

HTML部分

<v-chart ref="heartMap" class="heartMap" :option="option"></v-chart>

js部分

// 配置项
options: {
        // 背景图片设置
        graphic: [
          {
            type: "image",
            left: "0",
            top: "0",
            z: -10,
            bounding: "raw",
            rotation: 0, //旋转
            origin: [30, 55], //中心点
            scale: [0.9, 0.9], //缩放
            style: {
              // 背景图
              image: require("@/assets/images/11.png"),
              opacity: 1,
            },
          },
        ],
        series: [
          {
            type: "gauge",
            startAngle: 90,
            endAngle: -270,
            radius: "65%",
            center: [
              // 圆心
              "47%",
              "48%",
            ],
            pointer: {
              show: false,
            },
            itemStyle: {
              normal: {
                color: {
                  type: "linear",
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [
                    {
                      offset: 0,
                      color: "#F86921", // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "#FE9E27", // 100% 处的颜色
                    },
                  ],
                  global: false, // 缺省为 false
                },
                borderWidth: 3,
                label: {
                  show: false,
                },
                labelLine: {
                  show: false,
                },
                shadowOffsetX: 50,
                shadowOffsetY: 50,
                shadowBlur: 30,
              },
            },
            progress: {
              show: true,
              overlap: false,
              roundCap: true,
              clip: false,
              itemStyle: {
                borderWidth: 1,
              },
            },
            axisLine: {
              show: false,
            },
            splitLine: {
              show: false,
              distance: 0,
              length: 10,
            },
            axisTick: {
              show: false,
            },
            axisLabel: {
              show: false,
              distance: 50,
            },
            data: [
              {
                value: 0,
                name: "Perfect",
                title: {
                  show: false,
                  offsetCenter: ["0%", "-30%"],
                },
              },
            ],
            detail: {
              fontSize: 20,
              color: "#FFF",
              borderColor: "auto",
              formatter: function() {
                return getischargeOptions();
              },
              offsetCenter: [5, -5],
            },
          },
        ],
      }
      // 数据格式化
      const getischargeOptions = () => {
      return Number(options.series[0].data[0].value).toFixed(2) + '%';
    };

效果图

在这里插入图片描述

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值