Echarts环形图加自定义图片

echarts yekong

通过graphic将base64的图片渲染到echarts中
Echarts环形图加自定义图片

drawLine() {
      window.addEventListener('resize', this.drawLine)
      let myChart = this.$echarts.init(this.$refs.echarts)
      let value = 55.33
      let int = value.toFixed(2).split('.')[0]
      var giftImageUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAjCAYAAAD8BaggAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDcuMC1jMDAwIDc5LmRhYmFjYmIsIDIwMjEvMDQvMTQtMDA6Mzk6NDQgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCAyMi40IChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjQ0OEJGQkQzM0M5QzExRUM5QTc2RDkwMTEyMTVGQUI5IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjQ0OEJGQkQ0M0M5QzExRUM5QTc2RDkw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BnSNf1MrjF1vOottywp/9JNNRooqMn5K6Q8DfZ24E9QIYhwVJipUcLxnSat1C0NPLZqPednG4ytJsx/C1pDwSeQusT4l+nIBfaYqSU0LoaZkBD2h+SSHU1lZvBTfWWC4q6SXSDGfxprn+KJ/UJwJIIF1ad62Zw8z1o0svJ21dFuHCj8IVioM8/+NMvYH1I+UI8gFYoU/EADF54DY8Sh00Hxsdw6uGSfVY8iE2DumGLjqZR1wFXxbEXwLUYK1MesNcCCc3W3gEOw7edHrxGsaQc5Hn+T2AMtFcxI4swDbjMNX/7CvA4qe9vXthRIcjNkzz450GvVoTjTjAlzpEhFeORgJ0mbjIW2BVybjqftMW6A1PdAbmdrkNOkU56L3LPfZ5hTQ9MSxzx2vLBFTFWtQM8gSZhBxy3XdrTjRxykcZCcw6hH2RpzEisBDe4BZrX4QFQ2akzvIc5bGmEUA3qW8WgokZiq5h4oGJ0mfLMV2hHwRsivdn6BzVEvArFyVHbgGZ/Te0NqlnM8LnIzMxYcqaCKoK7MbbrCWSF3G4riu0D4O/8TVP/5qDTHVFqOBEnUChq7cCA/Df8A0lJaq/vwtEHRSt0PMLHi1qgPngdi1U56k8jLs8GF4vyxFScZypKjmfQeoNfBtp+0CcO/mnHfc8PFPlVjm4wZg7X6Q2kTJGpjTnJVn6nicLh+j4eHPGqy4BT/99BqUuOEPuvAAMA0DDPvmidUBEAAAAASUVORK5CYII="
      var option = {
        title: {
          text: '{a|' + int + '%}',
          x: 'center',
          show: false,
          y: 'center',
          textStyle: {
            rich: {
              a: {
                fontSize: 20,
                color: 'rgba(0, 156, 255, 1)'
              }
            }
          }
        },
        graphic: {
          elements: [{
            type: 'image',
            style: {
              image: giftImageUrl,
              width: FontChart(36),
              height: FontChart(35)
            },
            left: 'center',
            top: 'center'
          }]
        },
        series: [
          {
            type: 'gauge',
            radius: '90%',
            clockwise: true,
            startAngle: '90',
            endAngle: '-269.9999',
            splitNumber: 25,
            detail: {
              offsetCenter: [0, -10],
              formatter: ' '
            },
            pointer: {
              show: false
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: [
                  [0, 'rgba(0, 156, 255, 1)'],
                  [52 / 100, 'rgba(0, 156, 255, 1)'],
                  [1, 'rgba(0, 156, 255, 0)']
                ],
                width: 6
              }
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              length: 6,
              lineStyle: {
                color: '#485C68',
                width: 3
              }
            },
            axisLabel: {
              show: false
            }
          },
          {
            type: 'pie',
            name: '内层细圆环',
            radius: ['96%', '98%'],
            hoverAnimation: false,
            clockWise: false,
            itemStyle: {
              normal: {
                color: 'rgba(88, 118, 143, 1)'
              }
            },
            label: {
              show: false
            },
            data: [100]
          },
          {
            type: 'pie',
            name: '内层细圆环',
            radius: ['75%', '77%'],
            hoverAnimation: false,
            clockWise: true,
            itemStyle: {
              normal: {
                color: 'rgba(88, 118, 143, 1)'
              }
            },
            label: {
              show: false
            },
            data: [100]
          }
        ]
      }
      myChart.clear()
      myChart.resize()
      myChart.setOption(option)
    },
喜欢