echarts 地图 tooltip 显示图片

echarts yekong 178℃

wanjunshijiecom 2021-08-28 at 20.05.47@2x

      var data = [
        {
          name: '北京',
          value: 2
        }, {
          name: '天津',
          value: 5
        }, {
          name: '上海',
          value: 1
        }, {
          name: '重庆',
          value: 0
        }, {
          name: '河北',
          value: 0
        }, {
          name: '河南',
          value: 0
        }, {
          name: '云南',
          value: 0
        }, {
          name: '辽宁',
          value: 0
        }, {
          name: '黑龙江',
          value: 0
        }, {
          name: '湖南',
          value: 0
        }, {
          name: '安徽',
          value: 0
        }, {
          name: '山东',
          value: 0
        }, {
          name: '新疆',
          value: 0
        }, {
          name: '江苏',
          value: 0
        }, {
          name: '浙江',
          value: 0
        }, {
          name: '江西',
          value: 0
        }, {
          name: '湖北',
          value: 0
        }, {
          name: '广西',
          value: 0
        }, {
          name: '甘肃',
          value: 0
        }, {
          name: '山西',
          value: 0
        }, {
          name: '内蒙古',
          value: 0
        }, {
          name: '陕西',
          value: 0
        }, {
          name: '吉林',
          value: 5
        }, {
          name: '福建',
          value: 5
        }, {
          name: '贵州',
          value: 15
        }, {
          name: '广东',
          value: 15
        }, {
          name: '青海',
          value: 0
        }, {
          name: '西藏',
          value: 0
        }, {
          name: '四川',
          value: 0
        }, {
          name: '宁夏',
          value: 0
        }, {
          name: '海南',
          value: 0
        }]
      myChart.setOption({
        series: [{
          type: 'map',
          map: 'china'
        }]
      })
      const tooltipFormatter = function (params) {
        console.log(params)
        return `<div style="width: 100px;height: 46px;background: #0080EE;position: relative">
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAmCAYAAAAxxTAbAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bW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CV8oJWBgJsPHjHNoueQ6aY0ijxDqaAI4e4LMjAXZ9k8XcGi+OstvGvzB8W0b5K17jMl+RCa/KlL+B4SYt1spZUEenh0PnPNSVAnUcq6DMxMkZJYKGgcsXJHYeSmHn/gzqqwTSKRNXdHaNgtofInyLmRtqfd5zjalvILc5yAXvWotsI7KFsofd0Me1bFkjl/omjXm1EQKm3xoUONMm8MNpid4+ifoa22pjASL24dl+GmqNoG9Yt0mLACt5sC96j4nZTDazjbTyQta6gmtSlq1ouxbgg0uE0EQWLZy0Eiku59m0xpwHYhxpHfuT7T1vjF7HUyeAJnZG27zCUL8RqOiK9MR2XpyvtHFwrLTBLDHugjEGTjIORXqsUFnYq/1MeY3R0nGXHu8iukdFpnVkSO3l/DEuocydGT0KUUd3L6adW/bLWpv1TOugGS4So8wu5AejF8MwbGHlDzPpNk2dmG1GRTtYWjM/n/B7OF39vFsRPzYS6jVcz9ZyM/gtFjTalMx2dthjPNvKrzdnKtIzZzThGMfrJUZdjwuyMZ9zcF/npc5iO0FRcpj5GaPpz6RUHRhP95kLnJy25tmmY28ePiUFzzErxDNB44GXSUHQdzQhk/ymFUJ8gcuVS4a1FSBcck6yXExxKK65SdwyJj1WyGU+KonvAtU0BlPL0w9GW6i5t66V2CONnOgughlfv8Nd/2WYCa4T+B/G/yKEv1+KuzWM1637EFLc1YRiABBFLjeNHrJfMqbIa02x6tkvhhX8zEnypYVta4hxNPPDndAUYQetEkIcj+HMFUuITTx7lM+uKEZDb96iYEZlmHne/nFzs/fLPNtyhpvULl74vRgh/wowAI86mxvPx70wAAAAAElFTkSuQmCC" style="width:24px;position: absolute;left: -30px;" alt="">
        <div style="width: 100px;height: 46px; background: #0080EE;box-shadow:#0759AA 0 0 10px 2px;border-radius: 10px;">
        <div style="font-size: 12px; padding-left:5px;font-family: PingFang;font-weight: 500;color: #FFFFFF;">累计车位数:</div>
          <div style="font-size: 16px; padding-left:5px;font-family: DIN;font-weight: bold;color: #FFFFFF;">${params.data.value}</div>
      </div>
    </div>`
      }
      var option = {
        //地图显示:移动鼠标,显示数据
        tooltip: {
          trigger: 'item',
          showDelay: 0,
          transitionDuration: 0.2,
          borderWidth: 0,
          padding: 0,
          formatter: tooltipFormatter
        },
        //图例
        visualMap: {
          min: 19000,
          max: 70000,
          right: 10,
          bottom: 40,
          showLabel: !0,
          textStyle: {
            color: 'rgba(167, 194, 240, 1)'
          },
          pieces: [{
            gt: 10,
            lt: 20,
            label: '投放运营',
            color: 'rgba(255, 187, 5, 1)'
          }, {
            gt: 0,
            lt: 10,
            label: '战略部署',
            color: 'rgba(0, 228, 102, 1)'
          }, {
            gt: 0,
            lt: 0,
            label: '',
            color: '#00338F'
          }],
          show: !0
        },
        toolbox: {
          show: false,
          orient: 'vertical',
          left: 'right',
          top: 'center',
          feature: {
            dataView: {
              readOnly: false
            },
            restore: {},
            saveAsImage: {}
          }
        },
        geo: {
          map: 'china',
          zoom: 1,
          label: {
            normal: {
              show: false,
              color: '#000000'
            },
            emphasis: {
              show: false,
              color: '#292929'
            }
          },
          roam: true,
          itemStyle: {
            normal: {
              areaColor: '#00338F'
            },
          }
        },
        series: [{
          type: 'map',
          mapType: 'china',
          geoIndex: 0,
          itemStyle: {
            normal: {
              color: '#ccc',
              areaColor: '#00338F',
              borderColor: '#0094D6',
              borderWidth: 0.5,
              label: {
                show: false,
              }
            },
            emphasis: {
              areaColor: false,
              borderColor: '#00338F',
              areaStyle: {
                color: '#0094D6'
              },
              label: {
                show: false,
              }
            }
          },
          label: {
            normal: {
              show: false
            },
            emphasis: {
              show: false
            }
          },
          data: data
        }]
      }
喜欢 (0)