echarts实现省份迁徙图

本文详细介绍了如何使用ECharts实现带有省份边框阴影、迁徙图和图例的交互地图。通过引入JSON数据并注册地图,设置图层阴影,以及配置系列数据和图标,实现了地图的复杂视觉效果。文章还展示了具体的ECharts配置代码,包括地图纹理、阴影、颜色等细节设置。
摘要由CSDN通过智能技术生成

一、实现效果

在这里插入图片描述

二、分析

需求分析:

1、实现的省份图,边框的阴影是一层一层的
2、实现迁徙图
3、上面有小图标

三、实现的逻辑

1、引入json,注册registerMap(地图名字,引入json的名字)
2、geo中regions设置图层阴影
3、symbol放图标地址

四、代码

代码在别人的基础上改的,代码较多,较乱,有时间再整理

<template>
  <div class="echart-map-container">
    <div id="echartsDivMap" ref="echartsDivMap" class="is-echart"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
import ShanXiJsonObj from "@/components/echartsMapJson/spg_city1";
// import countiesJsonObj from "./spg_country";
// import piePatternSrc2 from "./image1"
// import piePatternSrc from "./image2"
// import axios from "axios";

export default {
  name: "EchartsMap",
  data() {
    return {
      myEcharts: null,
      regionNames: [],
      max: 0,
      min: 0,
      bigScreenWidth: 5124,
      defautlRegionName: "Shanxi", // 默认加载地图区域名称
      regionInfo: {
        regionCode: "",
        regionName: "",
      },
      barValueType: "unifiedLoad", // 柱形图上显示的数据 "unifiedLoad" 统调负荷, "unifiedElectricity"统调电量, "supplyLoad"上网负荷, "supplyElectricity"上网电量
      isChildRegion: false, // 当前正在显示区县地图
      cityGeoCoordMap: {}, // 城市中心点map
      cityInfos: {}, // 城市 名称-id-中心点
      countyGeoCoordMap: {}, // 区县中心点map
      countyInfos: {}, // 区县 名称-id-中心点
      currentCenter: [109.5996, 35.7396], // 当前地图中心点,默认是陕西的中心点
      defaultCenter: [109.5996, 35.7396], // 陕西中心点
      mapLinks: [],
    };
  },
  props: {},
  computed: {},
  watch: {},
  created() {
    this.initCityGeoCoordMap();
    // this.initCountyGeoCoordMap();
    // this.getMapLinks()
  },
  mounted() {
    this.$nextTick(() => {
      this.drawMapWidthData(this.defautlRegionName, ShanXiJsonObj);
    });
  },
  methods: {
    getMapLinks() {},
    drawMap() {},

    initCityGeoCoordMap() {
      let geoCoordMap = {},
        _cityInfos = {};
      let arr = ShanXiJsonObj.features;
      // 循环取出 城市名称和value值
      for (let j = 0; j < arr.length; j++) {
        let code = arr[j].properties.code;
        let center = arr[j].properties.center;
        let name = arr[j].properties.name;

        geoCoordMap[code] = center;
        let infoItem = { name, code, center };
        _cityInfos[name] = infoItem;
      }

      this.cityGeoCoordMap = geoCoordMap;
      this.cityInfos = _cityInfos;
    },

    // initCountyGeoCoordMap () {
    // 	let geoCoordMap = {}, _countyInfos = {};
    // 	let arr = countiesJsonObj.features;
    // 	// 循环取出 城市名称和value值
    // 	for (let j = 0; j < arr.length; j++) {
    // 		let code = arr[j].properties.code;
    // 		let center = arr[j].properties.center;
    // 		let name = arr[j].properties.NAME;

    // 		geoCoordMap[code] = center;
    // 		let infoItem = { name, code, center }
    // 		_countyInfos[name] = infoItem;
    // 	}

    // 	this.countyGeoCoordMap = geoCoordMap;
    // 	this.countyInfos = _countyInfos;
    // },

    // createGeoCoordMap_Child (regionCode) {
    // 	let cityJsonData = require('./echartsMapJson/myGeoCounties/' + regionCode + '.json');
    // 	let arr = cityJsonData.districts[0].districts;
    // 	let result = {};
    // 	for (let j = 0; j < arr.length; j++) {
    // 		let center = arr[j].center.split(',');
    // 		let centerArr = [+center[0], +center[1]];
    // 		result[arr[j].adcode] = centerArr;
    // 	}
    // 	return result;
    // },

    drawMapWidthData(jsonName, jsonData, geoCoordMap) {
      let that = this;
      let jsonName2 = jsonName + "2";
      echarts.registerMap(jsonName, jsonData);
      echarts.registerMap(jsonName2, jsonData);

      // that.myEcharts = echarts.init(that.$refs.echartsDivMap);
      let eleMapDiv = document.getElementById("echartsDivMap");
      that.myEcharts = echarts.init(eleMapDiv);

      let piePatternImg = new Image();
      // piePatternImg.src = piePatternSrc.piePatternSrc;

      let piePatternImg2 = new Image();
      // piePatternImg2.src = piePatternSrc2.piePatternSrc;

      // let center = that.myEcharts.convertToPixel('geo', that.currentCenter);
      // let mapTextureImg = import('../../assets/img/icon_shanxi_map.png');
      // let img = new Image();
      // img.src =  '../../assets/img/icon_shanxi_map.png';
      // img.width = '100%';
      // img.height = '100%';

      let domImg = document.createElement("img");
      domImg.style.height =
        domImg.height =
        domImg.width =
        domImg.style.width =
          "8px";
      domImg.src =
        "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAIAAAAmKNuZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkE4MTE0OTgyQTdDQzExRUI4Q0RBRkMwQkFGMTY2NDhEIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkE4MTE0OTgzQTdDQzExRUI4Q0RBRkMwQkFGMTY2NDhEIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTgxMTQ5ODBBN0NDMTFFQjhDREFGQzBCQUYxNjY0OEQiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QTgxMTQ5ODFBN0NDMTFFQjhDREFGQzBCQUYxNjY0OEQiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4v4trwAAAAVklEQVR42mL0D225cu0hAzWAjpY8C9CsL19/wIV4uDnI5gKNYmKgKhjcxrFAggBZiBIuyDhqRQWQOxoVo1ExGhWjUTEaFYMiKoB1LVq1TXZUAI0CCDAAcAlaxCt7dtQAAAAASUVORK5CYII=";

      //格式化数据
      let cityInfo_ = {};
      ShanXiJsonObj.features.map((item) => {
        return (cityInfo_[item.properties.name] = item.properties.centroid);
      });
      console.log(cityInfo_, "cityInfo_");
      let HHData = [
        [
          {
            name: "呼和浩特市",
          },
          {
            name: "鄂尔多斯市",
            value: 95,
          },
        ],
        [
          {
            name: "呼和浩特市",
          },
          {
            name: "乌兰察布市",
            value: 90,
          },
        ],
        [
          {
            name: "鄂尔多斯市",
          },
          {
            name: "阿拉善盟",
            value: "91",
          },
        ],
        [
          {
            name: "鄂尔多斯市",
          },
          {
            name: "巴彦淖尔市",
            value: "92",
          },
        ],
        [
          {
            name: "鄂尔多斯市",
          },
          {
            name: "包头市",
            value: "92",
          },
        ],
      ];
      //格式化文件
      let convertData = function (data) {
        let res = [];

        for (let i = 0; i < data.length; i++) {
          let dataItem = data[i];
          let fromCoord = cityInfo_[dataItem[0].name]; // 出发地的经纬度
          let toCoord = cityInfo_[dataItem[1].name]; // 目的地的经纬度
          if (fromCoord && toCoord) {
            res.push({
              fromName: dataItem[0].name,
              toName: dataItem[1].name,
              coords: [fromCoord, toCoord],
              value: dataItem[1].value,
            });
          }
        }
        return res;
      };
      // 图标定位
      let iconData = [
        {
          name: "阿拉善盟",
          value: [102.42556, 40.532392,240], //后面的是控制图标的大小
          type: "iconData",
        },
        {
          name: "锡林郭勒盟",
          value: [115.51632, 44.232965,240],
          type: "iconData",
        },
      ];
      let series = [];
      [["呼和浩特市", HHData],].forEach(function (item, index) {
        series.push(
          //图标的地址
          {
            name: "图标",
            type: "scatter",
            coordinateSystem: "geo",
            data: iconData,
            zlevel: 6,
            symbol: 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAACPCAYAAABHya34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3lpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDA2IDc5LmRhYmFjYmIsIDIwMjEvMDQvMTQtMDA6Mzk6NDQgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ODFmOWNiZDQtNjdmMC00NjQwLWI0O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hc8F+hzQeW/HFYApidGiDOjK+MGvttGwZ77FzCZNnJxuyR0TXHD9Qw9pau4xZwIDW5x+rq9yzvYyz1roEnuUZuYyiZXIanhzKe5ysp7ne2XL5bFP17m2l599fe7b6wL6qrgyv1NQpidqcl94YyyiUzOX/+XNBF8ZXDLQRKW7c1vh25K7BK/17V+H/uNdWjTeNnZqIgzrXydXL8qxFJbesghe469zX3pmowK7ffOpwTf7qlSeCmCa8i3yVr4N21xVk9typAas5cbTWNGxYjDZ1gD55zt1ptJxDzZcvNXdjBtz7FKRCTg966KFBI55/daxMEyW3XDxjPvHWG/nIy3Y1BijBstEvzW0kpiNgoEEN7dmdzqSxiFcd3Fel0Kvl0YOGxcQMHxuXNn9hGsVwqLWu2sF3HH32PjsWY1D2X3R3/zFLV+bGYamlsWuv3PVV8el33z4dROQNar8GU3NHwHQ1u+5yrhQ4iRzy1PPDo9KzjIGz39rjh2rrz51r8DQ09rpuuCIuVtUvJycuYcK0hMDZe0vZVcvFD9670Hi+oDGY9C6mP7adK/Uk7RDU7FqyOwnjx8an37skM3bY2DghoLqWlHawV5W3tmKyV1fbnRaLm3W6WK7F7vU9q5lCTJRWLlOrZGqjUalNStLqktN0Wkxt0w4UDhMaC041lH2ztbj2xKk6FFzU4Olodh3efEybXzd54qREMVE1dFQniapuTBwhUVV4VkxUVeUdq+mmFHYrH9PdDB6UkVwYTAavvdRm9MAsozY9I0rTL0mrMsWr5fpohVylkgWCBsx7XS7Wa2v2uMx1Tkd9td1eVtJiuXbVYr1WauuBYQc790+S4gx5Bi+wpZAU50TU28dIhLdJOV9IaVaGM+d7wwQb00+Qr9adpg8BArdSoD7eP0jOJagWSmACs2LjiJGG+0q3okQ0pE3PEqOaT4xst1o4gGmbEezencieS0VI70SG+xYtDO48ocAkdNt71wZCUhJcS34ksAtSbgd6K6Gw37tu2/5fgAEAVlRCMWj+9vMAAAAASUVORK5CYII=',
            // symbolSize: function (val) {
            //   return val[2] / 7.5;
            // }, //这里计算不太好计算,就写了固定的宽高
            symbolSize:  [40, 80],
            symbolOffset:[0,'-40%'],
            itemStyle: {
              normal:{
                shadowBlur: 20, // 阴影模糊级别
                shadowOffsetX: 3, // 阴影偏移量
                shadowOffsetY: 0, // 阴影偏移量
                // shadowColor: 'rgba(0,0,0,0.7)',
                shadowColor: "rgba(0,187,255,0.8)",
                top: '5%'
              }
            },
            z: 7
          },
          //两地之间的动态轨迹
          {
            name: item[0],
            type: "line",
            zlevel: 5,
            color: '#CECC43',
            effect: {
              show: true,
              period: 6, //箭头指向速度,值越小速度越快
              trailLength: 0.9, //特效尾迹长度[0,1]值越大,尾迹越长重
              symbol: "diamond", //箭头图标
              symbolSize: 3, //图标大小
              color: '#e6db30',
              loop:true,
            },
            lineStyle: {
              normal: {
                color: "#928464", //固定线的颜色
                width: 0.3, //尾迹线条宽度
                opacity: 1, //尾迹线条透明度
                // curveness: 0.3, //尾迹线条曲直度
                curveness: 0.1,
              },
            },
            data: convertData(item[1]),
          },
        );
      });
      console.log(series, 'series')

      let option = {
        animation: false,
        geo: [
          {
            map: jsonName, // 上面注册的地图名称
            // roam: true, // true-允许拖动和缩放
            // zoom: 1.155, // 地图初始大小
            // center: [116.366794, 40.400309], // 初始中心位置(这里不设置,表示使用默认值,就不需要每个地方都去设置一下了)
            // center: center,
            // layoutCenter: ['50%', '50%'],
            // layoutSize: '100%',
            
            label: {
              normal: {
                show: true, 
                
                color: "#7E7F81", //省份标签字体颜色
              },
              emphasis: {
                show: true,
                color: "#f75a00",
              },
            },
            itemStyle: {
              normal: {
                areaColor: "transparent", // 地区块儿颜色
                // borderColor: '#0ed7ff',
                // borderWidth: 2
              },
              // emphasis: {
              // areaColor: '#0ed7ff',
              // borderColor: '#fff900',
              // opacity: 0.4
              // }
            },
            regions: [
              // 这个是最上面的图层
              //对不同的区块进行着色
              {
                name: "呼伦贝尔市", //区块名称
                itemStyle: {
                  normal: {
                    borderColor: "#aaa",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                    borderColor: "#aaa",
                  },
                },
              },
              {
                name: "兴安盟",
                itemStyle: {
                  normal: {
                    borderColor: "#aaa",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                    borderColor: "#aaa",
                  },
                },
              },
              {
                name: "赤峰市",
                itemStyle: {
                  normal: {
                    borderColor: "#aaa",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                    borderColor: "#aaa",
                  },
                },
              },
              {
                name: "通辽市",
                itemStyle: {
                  normal: {
                    borderColor: "#aaa",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                    borderColor: "#aaa",
                  },
                },
              },
              {
                name: "呼和浩特市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "包头市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "乌海市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "鄂尔多斯市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "巴彦淖尔市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "乌兰察布市",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "锡林郭勒盟",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "阿拉善盟",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
              {
                name: "薛家湾",
                itemStyle: {
                  normal: {
                    borderColor: "#0ed7ff",
                    borderWidth: 2,
                  },
                },
                emphasis: {
                  itemStyle: {
                    areaColor: "#0ed7ff",
                    borderColor: "#fff900",
                    opacity: 0.4,
                  },
                },
              },
            ],
            z: 6,
          },
          {
            map: jsonName2, // 上面注册的地图名称 // 这层放纹理
            regions: [
              //对不同的区块进行着色
              {
                name: "呼伦贝尔市", //区块名称
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "兴安盟",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "赤峰市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "通辽市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg2,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "呼和浩特市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "包头市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "乌海市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "鄂尔多斯市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "巴彦淖尔市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "乌兰察布市",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "锡林郭勒盟",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "阿拉善盟",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
              {
                name: "薛家湾",
                itemStyle: {
                  normal: {
                    areaColor: {
                      image: piePatternImg,
                      repeat: "repeat",
                    },
                  },
                },
              },
            ],
            z: 5,
            silent: true,
          },
          {
            map: jsonName2, // 上面注册的地图名称 这层放最上面的黑色阴影
            itemStyle: {
              normal: {
                areaColor: "#172532", // 地区块儿颜色
                shadowBlur: 1, // 阴影模糊级别
                shadowOffsetX: 0, // 阴影偏移量
                shadowOffsetY: 5, // 阴影偏移量
                // shadowColor: 'rgba(0,0,0, 0.9)',
                // shadowColor: 'rgba(0,187,255, 0.5)',
                shadowColor: "#172532",
                // opacity: 0.8
              },
            },
            z: 4,
            silent: true,
          },
          {
            map: jsonName2, // 上面注册的地图名称  这层放下面的蓝色描边
            itemStyle: {
              normal: {
                areaColor: "#fff", // 地区块儿颜色
                shadowBlur: 2, // 阴影模糊级别
                shadowOffsetX: 0, // 阴影偏移量
                shadowOffsetY: 7, // 阴影偏移量
                // shadowColor: 'rgba(0,255,255)',
                // shadowColor: 'rgba(0,187,255, 0.5)',
                shadowColor: "#20aabb",
                // opacity: 0.8
              },
            },
            z: 3,
            silent: true,
          },
          {
            map: jsonName2, // 上面注册的地图名称  这层放下面的蓝色发光
            itemStyle: {
              normal: {
                areaColor: "#00bbff", // 地区块儿颜色
                shadowBlur: 5, // 阴影模糊级别
                shadowOffsetX: 2, // 阴影偏移量
                shadowOffsetY: 12, // 阴影偏移量
                // shadowColor: 'rgba(0,0,0,0.7)',
                shadowColor: "rgba(0,187,255,0.5)",
                // opacity: 0.8
              },
            },
            z: 2,
            silent: true,
          },
          {
            map: jsonName2, // 上面注册的地图名称  这层放最下面的黑色发光
            itemStyle: {
              normal: {
                areaColor: "#fff", // 地区块儿颜色
                shadowBlur: 5, // 阴影模糊级别
                shadowOffsetX: 2, // 阴影偏移量
                shadowOffsetY: 20, // 阴影偏移量
                shadowColor: "rgba(0,0,0,0.7)",
                // opacity: 0.8
              },
            },
            z: 1,
            silent: true,
          },
        ],
        series: series,
      };
      console.log(option,'option')
      // setTimeout(function () {
      //   let rawData = that.createRawData();
      //   that.renderEachCity(that.myEcharts, geoCoordMap, rawData);
      // }, 0);

      that.myEcharts.setOption(option, true); // 渲染地区,需要清空上次渲染的数据

      //防止重复触发点击事件
      if (that.myEcharts._$handlers.click) {
        that.myEcharts._$handlers.click.length = 0;
      }
      that.myEcharts.on("click", function (e) {
        let findItem = that.mapLinks.find((item) => item.cityName == e.name);
        if (findItem != undefined) {
          let tempWindow = window.open("_blank");
          tempWindow.location = findItem.cityLink;
        }
        return;
      });
    },

    createRawData() {
      let result = [];

      if (
        this.propsShowDatas &&
        this.propsShowDatas.datas &&
        this.propsShowDatas.datas.length
      ) {
        let arr = this.propsShowDatas.datas;
        this.max = 0;
        this.min = 0;
        // 循环取出 城市名称和value值
        for (let j = 0; j < arr.length; j++) {
          let data = +arr[j][this.barValueType];
          this.max = this.max > data ? this.max : data;
          this.min = this.min < data ? this.min : data;
          let item = [arr[j].regionCode, data, arr[j].regionName];
          result.push(item);
        }
      }

      return result;
    },

    renderEachCity(myChart, geoCoordMap, rawData) {
      let that = this;
      let option = { xAxis: [], yAxis: [], grid: [], series: [] };

      // echarts.util.each(rawData, function (dataItem, idx) {
      //   let geoCoord = geoCoordMap[dataItem[0]];
      //
      //   // if (!geoCoord) {
      //   //   continue;
      //   // }
      //
      //   let coord = myChart.convertToPixel('geo', geoCoord);
      //
      //   idx += '';
      //
      //   let data = [dataItem[1]];
      //
      //   option.xAxis.push({
      //     id: idx,
      //     gridId: idx,
      //     type: 'category',
      //     name: that.formatRegionName(dataItem[2]), // 柱形图下面显示的区域名称
      //     nameLocation: 'middle',
      //     splitLine: {
      //       show: false
      //     },
      //     axisTick: {
      //       show: false
      //     },
      //     axisLabel: {
      //       show: false
      //     },
      //     axisLine: {
      //       show: false,
      //       onZero: false,
      //       lineStyle: {
      //         color: '#e0e0e0'
      //       }
      //     },
      //     z: 100
      //   });
      //   option.yAxis.push({
      //     id: idx,
      //     min: that.min,
      //     max: that.max,
      //     gridId: idx,
      //     splitLine: {
      //       show: false
      //     },
      //     axisTick: {
      //       show: false
      //     },
      //     axisLabel: {
      //       show: false
      //     },
      //     axisLine: {
      //       show: false,
      //       lineStyle: {
      //         color: '#1C70B6'
      //       }
      //     },
      //     z: 100
      //   });
      //   option.grid.push({
      //     id: idx,
      //     width: that.convertSize(30),
      //     height: that.convertSize(40),
      //     left: that.convertSize(coord[0] - 20),
      //     top: that.convertSize(coord[1] - 55),
      //     z: 100
      //   });
      //   let barWidth = that.convertSize(8);
      //   option.series.push({
      //     // id: idx,
      //     type: 'bar',
      //     barWidth: barWidth,
      //     xAxisId: idx,
      //     yAxisId: idx,
      //     // barGap: 0,
      //     // barCategoryGap: 0,
      //     data: data,
      //     z: 10,
      //     itemStyle: {
      //       normal: {
      //         label: {
      //           show: true,
      //           borderColor: '#FFA32C',
      //           borderWidth: 1,//that.convertSize(2),
      //           borderRadius: that.convertSize(16),
      //           padding: that.convertSize(5),
      //           backgroundColor: '#190B02',
      //           position: 'top',	//在上方显示
      //           textStyle: {	    //数值样式
      //             color: '#FFA32C',
      //             fontSize: that.convertSize(10),
      //           },
      //           formatter: function (params) {
      //             let val = params.data;
      //             let type = that.barValueType == 'unifiedLoad' || that.barValueType == 'supplyLoad' ? 'MW' : 'MWh'
      //             return val + 'type';
      //           }
      //         },
      //         barBorderRadius: that.convertSize(12),
      //         color: new echarts.graphic.LinearGradient(
      //           0, 0, 0, 1,
      //           [
      //             {offset: 1, color: '#F77E2F'},
      //             {offset: 0, color: '#FFCD56'}
      //           ]
      //         )
      //       },
      //       emphasis: {
      //         barBorderRadius: that.convertSize(13),
      //         shadowBlur: that.convertSize(18),
      //         shadowColor: 'rgba(218,170, 58, 0.7)'
      //       }
      //     }
      //   });
      //   option.series.push({
      //     type: 'pictorialBar',
      //     xAxisId: idx,
      //     yAxisId: idx,
      //     symbolSize: [barWidth, that.convertSize(5)],
      //     symbolOffset: [0, 0],
      //     symbolPosition: 'end',
      //     z: 998,
      //     color: "#FF9600",
      //     data: data,
      //   });
      //   option.series.push({
      //     type: 'pictorialBar',
      //     xAxisId: idx,
      //     yAxisId: idx,
      //     symbolSize: [barWidth, that.convertSize(5)],
      //     symbolOffset: [0, 0],
      //     // symbolPosition: 'end',
      //     z: 999,
      //     color: "#E05800",
      //     data: data,
      //   });
      //   option.series.push({
      //     type: 'pictorialBar',
      //     xAxisId: idx,
      //     yAxisId: idx,
      //     symbolSize: [barWidth * 2, that.convertSize(5) * 2],
      //     symbolOffset: [0, 4],
      //     // symbolPosition: 'end',
      //     z: 1,
      //     color: "rgba(0,0,0,0.6)",
      //     data: data,
      //   });
      //   option.series.push({
      //     type: 'pictorialBar',
      //     xAxisId: idx,
      //     yAxisId: idx,
      //     symbolSize: [barWidth * 3, that.convertSize(5) * 2.5],
      //     symbolOffset: [0, 5],
      //     // symbolPosition: 'end',
      //     z: 1,
      //     color: "rgba(0,0,0,0.3)",
      //     data: data,
      //   });
      // });
      for (let idx = 0; idx < rawData.length; idx++) {
        let dataItem = rawData[idx];
        let geoCoord = geoCoordMap[dataItem[0]];

        if (!geoCoord) {
          console.log(
            dataItem[0] + "的geojson数据和服务器返回不一致(本地没有这个id)"
          );
          continue;
        }

        let coord = myChart.convertToPixel("geo", geoCoord);

        idx += "";

        let data = [dataItem[1]];

        option.xAxis.push({
          id: idx,
          gridId: idx,
          type: "category",
          name: that.formatRegionName(dataItem[2]), // 柱形图下面显示的区域名称
          nameLocation: "middle",
          nameTextStyle: {
            color: "#fff",
            // fontWeight:'bold',
            fontSize: 14,
          },
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
          offset: -35,
          axisLine: {
            show: false,
            onZero: false,
            lineStyle: {
              color: "#ffffff",
            },
          },
          z: 100,
        });
        option.yAxis.push({
          id: idx,
          min: that.min,
          max: that.max,
          gridId: idx,
          position: "left",
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
          offset: -31,
          axisLine: {
            show: false,
            lineStyle: {
              color: "#1C70B6",
            },
          },
          z: 100,
        });
        option.grid.push({
          id: idx,
          width: that.convertSize(30),
          height: that.convertSize(40),
          left: that.convertSize(coord[0] - 20),
          top: that.convertSize(coord[1] - 35),
          z: 100,
        });
        // let barWidth = that.convertSize(8);
        // option.series.push({ // 圆柱
        //   // id: idx,
        //   type: 'bar',
        //   barWidth: barWidth,
        //   xAxisId: idx,
        //   yAxisId: idx,
        //   // barGap: 0,
        //   // barCategoryGap: 0,
        //   data: data,
        //   z: 102,
        //   itemStyle: {
        //     normal: {
        //       label: {
        //         show: true,
        //         borderColor: '#FFA32C',
        //         borderWidth: 1,//that.convertSize(2),
        //         borderRadius: that.convertSize(16),
        //         padding: that.convertSize(5),
        //         backgroundColor: '#190B02',
        //         position: 'top',	//在上方显示
        //         textStyle: {	    //数值样式
        //           color: '#FFA32C',
        //           fontSize: that.convertSize(10),
        //         },
        //         formatter: function (params) {
        //           let val = params.data;
        //           let type = that.barValueType == 'unifiedLoad' || that.barValueType == 'supplyLoad' ? 'MW' : 'MWh'
        //           return val + type;
        //         }
        //       },
        //       barBorderRadius: that.convertSize(12),
        //       color: new echarts.graphic.LinearGradient(
        //         0, 0, 0, 1,
        //         [
        //           {offset: 1, color: '#F77E2F'},
        //           {offset: 0, color: '#FFCD56'}
        //         ]
        //       )
        //     },
        //     emphasis: {
        //       barBorderRadius: that.convertSize(13),
        //       shadowBlur: that.convertSize(18),
        //       shadowColor: 'rgba(218,170, 58, 0.7)'
        //     }
        //   }
        // });
        // option.series.push({ // 圆柱上面的椭圆(圆柱的顶面)
        //   type: 'pictorialBar',
        //   xAxisId: idx,
        //   yAxisId: idx,
        //   symbolSize: [barWidth, that.convertSize(5)],
        //   symbolOffset: [0, 0],
        //   symbolPosition: 'end',
        //   z: 103,
        //   color: "#FF9600",
        //   data: data,
        // });
        // option.series.push({ // 圆柱下面的椭圆(圆柱的底面)
        //   type: 'pictorialBar',
        //   xAxisId: idx,
        //   yAxisId: idx,
        //   symbolSize: [barWidth, that.convertSize(5)],
        //   symbolOffset: [0, 0],
        //   // symbolPosition: 'end',
        //   z: 103,
        //   color: "#E05800",
        //   data: data,
        // });
        // option.series.push({ // 圆柱下面的内圈阴影
        //   type: 'pictorialBar',
        //   xAxisId: idx,
        //   yAxisId: idx,
        //   symbolSize: [barWidth * 2, that.convertSize(5) * 2],
        //   symbolOffset: [0, 4],
        //   // symbolPosition: 'end',
        //   z: 101,
        //   color: "rgba(0,0,0,0.6)",
        //   data: data,
        // });
        // option.series.push({ // 圆柱下面的外圈阴影
        //   type: 'pictorialBar',
        //   xAxisId: idx,
        //   yAxisId: idx,
        //   symbolSize: [barWidth * 3, that.convertSize(5) * 2.5],
        //   symbolOffset: [0, 5],
        //   // symbolPosition: 'end',
        //   z: 100,
        //   color: "rgba(0,0,0,0.3)",
        //   data: data,
        // });
      }
      myChart.setOption(option, false); // 渲染地图区域上的柱形图,需要保留之前渲染的地图区域数据
    },

    formatRegionName(oldName) {
      if (
        oldName.length > 2 &&
        (oldName.endsWith("市") ||
          oldName.endsWith("县") ||
          oldName.endsWith("区"))
      ) {
        let result = oldName.substring(0, oldName.length - 1);
        return result;
      }
      return oldName;
    },

    convertSize(size) {
      let screenWidth = document.body.clientWidth;
      screenWidth = screenWidth >= 1920 ? screenWidth : 1920;
      let result = size * (screenWidth / this.bigScreenWidth) * 2.7;
      return result;
    },
  },
};
</script>

<style scoped>
.echart-map-container {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

.echart-map-container .map-back {
  background-size: 100% 100%;
  cursor: pointer;
  z-index: 999;
  display: inline-block;
}

.echart-map-container .map-back:hover {
  background-color: rgba(0, 0, 0, 0.4);
}

.is-echart {
  /* height: 100%;
    width: 100%; */
  height: 800px;
  width: 800px;
}
</style>



评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值