echarts地圖tooltip添加標注


myCharts.setOption({
          tooltip: {
              triggerOn: 'click',
              enterable: true,
              formatter: function(params, ticket, callback) {
                  console.log(params.length)
                  let content = {
                      area: 1,
                      areaName: params.name
                  }
                  let result = that.$axios({
                      method: 'get',
                      url: that.getMapCompany,
                      params: content
                  }).then(res => {
                      console.log(params, content, 'log')
                  })
                  var tipHtml = '';
                  tipHtml = '<div style="width:200px;height:200px;background:rgba(22,80,158,0.8);border:1px solid rgba(7,166,255,0.7)">'
                  +'<div style="width:100%;height:40px;line-height:40px;border-bottom:2px solid rgba(7,166,255,0.7);margin-bottom:10px;">'
                  +'<span style="margin-left:10px;color:#fff;font-size:16px;">'+ params.name +'</span>'+'</div>'
                  +'<div>'
                  +'<p style="color:#fff;font-size:12px;">'+'<i style="display:inline-block;width:8px;height:8px;background:#16d6ff;margin:0 8px">'+'</i>'
                  +'公司數量:'+'<span style="color:#f48225;margin:0 6px;">'+3+'</span>'+'個'+'</p>'
                  +'<p style="color:#fff;font-size:12px;">'+'<i style="display:inline-block;width:8px;height:8px;background:#16d6ff;margin:0 8px">'+'</i>'
                  +'被考核主體數量'+'<span style="color:#f4e925;margin:0 6px;">'+4+'</span>'+'個'+'</p>'
                  +'</div>'+'</div>';
                  return tipHtml;
 
                  return result;
                   
                   
              }
          },
          series: [
              {
                  type: 'map',
                  map: 'china',
                  zoom: 1,
                  label: {
                      show: true,
                      color: 'white',
                      fontSize: 10
                  },
                  itemStyle: {
                      normal: {
                          borderWidth: 2,//邊際線大小
                          borderColor:'#00ffff',//邊界線顏色
                          areaColor:'#09295b'//默認區域顏色
                      },
                      emphasis: {
                          show: true,
                          areaColor: '#3066ba',//鼠標滑過區域顏色
                          label: {
                              show: true,
                              textStyle: {
                                  color: '#fff'
                              }
                          }
                      }
                       
                  },
              }
          ],
      })

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM