vue+echart地图+弹窗

<template>
  <div id="gbznt" class="gbznt" ref="gbznt">
    <div id="mapContainer" class="mapContainer"></div>
  </div>
</template>
<script>
  let flag= 1
  import * as echarts from "echarts";
  let hdOption, initEcharts;
  import $ from 'jquery'
  import drill from '@/utils/drill'
  var aTimer;
  export default {
    name: 'centerMap',
    data(){
      let areaColor=['#56CCFB', '#0160AD'];
      let borderColor='#37C1FD';
      let emphasizeColor="#0160AD";
      let labelColor=['#bafdff', '#ffffff'];
      return{
        tmpLunboInfo:{
          index: 0,
          areaColor: {
            type: 'radial',
            x: 0.7,
            y: 0.5,
            r: 0.4,
            colorStops: [{
              offset: 0,
              color: '#56CCFB' // 0% 处的颜色
            }, {
              offset: 1,
              color: '#0160AD' // 100% 处的颜色
            }],
            global: false // 缺省为 false
          },
        },
        tmpLunboInfo1:{
          index: 0,
          areaColor: {
            type: 'radial',
            x: 0.6,
            y: 0.6,
            r: 1,
            colorStops: [{
              offset: 0,
              color: '#0d61ab' // 0% 处的颜色
            },{
              offset: 0.5,
              color: 'rgb(255,250,0)' // 100% 处的颜色
            },{
              offset: 1,
              color: 'rgb(251,255,2)' // 100% 处的颜色
            }],
            global: false // 缺省为 false
          },
        },
        mapIndex:1,
        isClick: false,
        regionsData:[
          {
            name: '黄岛区',
            value: [120.095262, 36.101767],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '红石崖街道',
            value: [120.095262, 36.101767],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '黄岛街道',
            value: [120.223051, 36.044854],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '薛家岛街道',
            value: [120.209532, 35.960284],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '辛安街道',
            value: [120.139688, 36.019265],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '王台镇',
            value: [120.002972, 36.0779441],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '灵珠山街道',
            value: [120.085354, 36.0163451],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '长江路街道',
            value: [120.156758, 35.949159],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '灵山卫街道',
            value: [120.140558, 35.941005],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '隐珠街道',
            value: [120.020412, 35.841401],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '宝山镇',
            value: [119.895833, 36.001432],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '六汪镇',
            value: [119.784986, 35.944079],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '铁山街道',
            value: [119.93574, 35.902106],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '珠山街道',
            value: [119.982206, 35.881178],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '珠海街道',
            value: [119.999568, 35.848121],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '滨海街道',
            value: [119.977144, 35.821489],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '张家楼镇',
            value: [119.926292, 35.793926],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '大村镇',
            value: [119.72593, 35.805443],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '藏马镇',
            value: [119.815722, 35.756631],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '琅琊镇',
            value: [119.858827, 35.686819],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '泊里镇',
            value: [119.78662, 35.7045341],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '大场镇',
            value: [119.638675, 35.674932],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          },
          {
            name: '海青镇',
            value: [119.569741, 35.659232],
            totals:'186.85',
            xZzArea:'88.21',
            xLsYield:'816.85',
            qZzArea:'88.22',
            qLsYield:'956.85',
            itemStyle: {
              areaColor: {
                type: 'radial',
                x: 0.7,
                y: 0.5,
                r: 0.4,
                colorStops: [{
                  offset: 0,
                  color:areaColor[0] // 0% 处的颜色
                }, {
                  offset: 1,
                  color:areaColor[1] // 100% 处的颜色
                }],
                global: false // 缺省为 false
              },
              borderColor:borderColor,
              borderWidth: 2,
              //选中效果
              emphasis: {
                areaColor:emphasizeColor, // hover效果
              },
            },
            label: {
              textStyle: {
                color:labelColor[0]
              }
            },
          }
        ]
      }
    },
    methods: {
      initChartMap(){
        var _this = this;
        initEcharts=echarts.init(document.getElementById('mapContainer'))
        initEcharts.clear()
        var huangDao = "../js/huangdao.json";
        var url = huangDao;
        $.getJSON(url, function (geoJson) {

          hdOption = {
            backgroundColor: 'rgba(128, 128, 128, 0.0)', //rgba设置透明度0.1
            color: ['#D4EDF2', '#00BDFE', '#FACA32'],
            grid: {
              top: "2%", // 等价于 y: '16%'
              left: "2%",
              right: "2%",
              bottom: "2%",

            },
            geo: [
              //底层地图
              {
                map: 'huangDao',
                aspectScale: 0.9,
                roam: false, //是否允许缩放
                //zoom: 1.1, //默认显示级别
                layoutSize: '95%',
                layoutCenter: ['50%', '52%'],
                itemStyle: {
                  areaColor: '#0d376f',
                  borderColor: '#0080d8',
                  borderWidth: 2,
                },
                // zlevel: 1,
                silent: true,
              },
              {
                map: 'huangDao',
                aspectScale: 0.9,
                roam: false, //是否允许缩放
                //zoom: 1.1, //默认显示级别
                layoutSize: '95%',
                layoutCenter: ['50%', '50%'],
                regions: _this.regionsData,
                // zlevel: 2,
                silent: false,
                label: {
                  show: true
                }
              },
            ],
            tooltip: {
              show: true,
              trigger: 'item', //触发类型。item,axis,none
              enterable: true,//鼠标是否可进入提示框浮层中,默认为false,
              showContent: true,      //是否显示提示框浮层
              triggerOn: 'none', //提示框触发的条件(mousemove|click|none)
              //showDelay: 200,         //浮层显示的延迟,单位为 ms,默认没有延迟,也不建议设置。在 triggerOn 为 'mousemove'有效。
              textStyle: {
                color: 'white',
                fontSize: 12
              },
              padding: [0, 8],
              position: function(point, params, dom, rect, size) {
                // 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
                // 提示框位置
                var x = 0; // x坐标位置
                var y = 0; // y坐标位置

                // 当前鼠标位置
                var pointX = point[0];
                var pointY = point[1];
                // 提示框大小
                var boxWidth = size.contentSize[0]/2;
                var boxHeight = size.contentSize[1]+50;

                // boxWidth > pointX 说明鼠标左边放不下提示框
                if (boxWidth > pointX) {
                  x = 5;
                } else { // 左边放的下
                  x = pointX - boxWidth;
                }

                // boxHeight > pointY 说明鼠标上边放不下提示框
                if (boxHeight > pointY) {
                  y = 5;
                } else { // 上边放得下
                  y = pointY - boxHeight;
                }
                return [x, y];
              },
              // hideDelay: 10,
              formatter: (o) => {
                var arr=_this.regionsData
                let _str = ``;
                for(var i in arr){
                  if(arr[i].name == o.name){
                    _str+=`<div class="echart-dialog">`
                    if (_this.isClick){
                      _str+=`<span onclick="returnArea()" class="echarts-close"></span>`
                    }
                /*    _str+=`<div class="echart-dialog-head">${arr[i].name}</div>
                        <div class="echart-dialog-item">
                          <div class="e-d-t">在线数/联网农机数</div>
                          <div class="e-d-n">
                            <span class="e-d-n1">${arr[i].inlineNum}</span>
                            <span class="e-d-n2">/${arr[i].inlineNums}</span>
                            辆
                          </div>
                        </div>
                        <div class="echart-dialog-item">
                          <div class="e-d-t">作业面积</div>
                          <div class="e-d-n">
                                <span class="e-d-n2">${arr[i].work}</span>亩
                          </div>
                        </div>
                        <div class="echart-dialog-item">
                          <div class="e-d-t">补贴金额</div>
                          <div class="e-d-n">
                                <span class="e-d-n2">${arr[i].money}</span>万元
                          </div>
                        </div>
                        </div>`*/
                    _str+=`<div class="echart-dialog-head">${arr[i].name}</div>
                        <div class="echart-item">
                          <div class="gdLeft">
                              <div class="item-left">${arr[i].totals}</div>
                              <div class="lableName">耕地面积(万亩)</div>
                          </div>
                          <div class="gdRight">
                            <div class="gdRight-item">
                                <div class="gdRight-Name">夏粮</div>
                                <div class="gdRight-item1">
                                    <div class="e-d-t">种植面积</div>
                                    <div class="e-d-n">
                                      <span class="e-d-n1">${arr[i].xZzArea}</span>万亩
                                    </div>
                                </div>
                                <div class="gdRight-item1">
                                  <div class="e-d-t">粮食产量</div>
                                  <div class="e-d-n">
                                    <span class="e-d-n1">${arr[i].xLsYield}</span>万吨
                                  </div>
                               </div>
                            </div>

                             <div class="gdRight-item">
                                <div class="gdRight-Name">秋粮</div>
                                <div class="gdRight-item1">
                                    <div class="e-d-t">种植面积</div>
                                    <div class="e-d-n">
                                      <span class="e-d-n1">${arr[i].qZzArea}</span>万亩
                                    </div>
                                </div>
                                <div class="gdRight-item1">
                                  <div class="e-d-t">粮食产量</div>
                                  <div class="e-d-n">
                                    <span class="e-d-n1">${arr[i].qLsYield}</span>万吨
                                  </div>
                               </div>
                            </div>
                          </div>

                        </div>

                        </div>`
                    return _str;
                  }
                }
              },
              extraCssText: 'box-shadow: none',
              borderWidth:'0',
              boxShadow:'none',
              backgroundColor: 'none',  //提示框浮层的背景颜色。
              alwaysShowContent: true,
              transitionDuration: 1,      //提示框浮层的移动动画过渡时间,单位是 s,设置为 0 的时候会紧跟着鼠标移动。
            },
            legend: {show: false},
            //配置属性
            series: [
              {
                name: '自定义图标',
                map: 'huangDao',
                type: "scatter",
                coordinateSystem: "geo",
                symbolSize: 0,
                silent: 'none',
                data: _this.regionsData.map(item => {
                  return {
                    name: item.name,
                    value: item.value
                  };
                })
              }
            ],
            visualMap: {show: false},
          }
          //地图组件
          echarts.registerMap("huangDao", geoJson);
          // 使用刚指定的配置项和数据显示图表。
          initEcharts.setOption(hdOption);
          // 开始轮播
          aTimer = setInterval(_this.setMapArea, 5000);

          initEcharts.on('mouseOver', function (e) {//停止轮播
            if (!_this.isClick){
              _this.mapIndex = _this.regionsData.findIndex(rec => rec.name === e.name);
              if(aTimer !== '') clearInterval(aTimer)
              aTimer = ''
              _this.regionsData[_this.tmpLunboInfo.index].itemStyle.areaColor = _this.tmpLunboInfo.color;
              _this.tmpLunboInfo.index = _this.mapIndex;
              _this.tmpLunboInfo.color = _this.regionsData[_this.mapIndex].itemStyle.areaColor;
              _this.regionsData[_this.mapIndex].itemStyle.areaColor =  _this.tmpLunboInfo1.areaColor;
              hdOption.geo[1].regions = _this.regionsData;
              initEcharts.clear()
              initEcharts.setOption(hdOption);
              initEcharts.dispatchAction({
                type: 'showTip',
                seriesIndex: 0,
                dataIndex: _this.mapIndex
              });
              _this.mapIndex++
            }
          })
          initEcharts.on('mouseOut', function (e) {
            if (!_this.isClick){
              if (aTimer != '') clearInterval(aTimer)
              aTimer = setInterval(_this.setMapArea, 5000);
            }
          })
          initEcharts.on('click', function (e) {
            if (e.name==='海青镇' || e.name==='张家楼镇'){
              clearInterval(aTimer)
              aTimer = ''
              _this.isClick = true;
              _this.mapIndex = _this.regionsData.findIndex(rec => rec.name === e.name);
              _this.setMapArea()
              drill.$emit('changeLeftArea',e.name)
              drill.$emit('changeRightArea',e.name)
            }
          })
        })
      },
      returnArea(){
        this.isClick = false
        this.setMapArea()
        aTimer = setInterval(this.setMapArea, 5000);
        drill.$emit('changeLeftArea','')
        drill.$emit('changeRightArea','')
      },
      setMapArea() {
        var _this = this;
        _this.mapIndex = _this.mapIndex % _this.regionsData.length;
        if (_this.mapIndex === 0) {
          _this.mapIndex++
        }
        _this.regionsData[_this.tmpLunboInfo.index].itemStyle.areaColor = _this.tmpLunboInfo.color;
        _this.tmpLunboInfo.index = _this.mapIndex;
        _this.tmpLunboInfo.color = _this.regionsData[_this.mapIndex].itemStyle.areaColor;
        _this.regionsData[_this.mapIndex].itemStyle.areaColor = _this.tmpLunboInfo1.areaColor;
        hdOption.geo[1].regions = _this.regionsData;
        initEcharts.clear()
        initEcharts.setOption(hdOption);
        initEcharts.dispatchAction({
          type: 'showTip',
          seriesIndex: 0,
          dataIndex: _this.mapIndex
        });
        _this.mapIndex++;
      }
    },
   created() {
      window.returnArea =this.returnArea
  },
    mounted() {
      if(flag == 1){
        flag = 0
        this.initChartMap()
      }

    },

  };
</script>

<style lang="scss" scoped>
  .gbznt {
    width: 100%;
    height: 100%;
  }
  .mapContainer {
    width: 50vw;
    height: 86vh;
    top: 4vh;
    left: 25vw;
    position: relative;
  }

  .gbznt::v-deep .echart-dialog {
    position: relative;
    top: 0;
    left: 0;
    padding: 13px 15px;
    width: 418px;
    height: 275px;
    background-image: url("../../img/machineryManagement/map/e-d-bg.png");
    background-size: 100% 100%;
    .echarts-close{
      position: absolute;
      right: 26px;
      top: 27px;
      width: 15px;
      height: 15px;
      background-image: url("../../img/machineryManagement/map/mao-close.png");
      background-size: 100% 100%;
      cursor: pointer;
    }
    .echart-dialog-head{
      width: 100%;
      height: 42px;
      font-size: 14px;
      line-height: 45px;
      text-align: left;
      padding-left: 10px;
     /* background-image: url("../../img/map/e-d-h-bg.png");
      background-size: 100% 100%;*/
    }
    .echart-dialog-head::after{
      content: "";
      width: 418px;
      height: 1px;
      pointer-events: none;
      user-select: none;
      background-image: url("../../img/machineryManagement/main2/line.png");
      background-size: 100% 100%;
      position: absolute;
      z-index: 5;
      left: 15px;
      top: 52px;
    }
    .echart-dialog-item{
      width: 100%;
      height: 30px;
      line-height: 30px;
      text-align: left;
      padding-left: 10px;
      display: flex;
      .e-d-t{
        color: #848b9a;
        width: 120px;
        font-size: 12px;
      }
      .e-d-n{
        color: #78bafc;
        width: 80px;
        text-align: right;
        .e-d-nNum{
          font-size: 28px;
          font-family: Bahnschrift;
          color: #78bafc;
        }
        .e-d-n2{
          font-size: 14px;
        }
      }
    }
    .echart-item{
      width: 100%;
      height: calc(100% - 45px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 1vh 1.2vw;
      .gdLeft{
        width: 123px;
        height: 100%;
        .item-left{
          margin-top: 1vh;
          width: 125px;
          height: 133px;
          background-image: url("../../img/planting/main1/alertBg.png");
          background-size: 100% 100%;
          font-size: 2.4vh;
          font-family: Bahnschrift;
          line-height: 133px;
          color: #ffb628;
        }
        .lableName{
          font-size: 1vh;
          color: #848b9a;
          margin-top: 1vh;
        }
      }
      .gdRight{
        width: 205px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        .gdRight-item{
          width: 100%;
          height: 85px;
          background-image: url("../../img/planting/main1/dialogBg.png");
          background-size: 100% 100%;
          padding: 0 0.5vw;
          .gdRight-Name{
            text-align: left;
            margin-top: 1vh;
          }
          .gdRight-item1{
            display: flex;
            text-align: left;
            height: 2.6vh;
            line-height: 2.6vh;
            .e-d-t{
              color: #848b9a;
              width: 120px;
              font-size: 12px;
            }
            .e-d-n{
              color: #78bafc;
              width: 80px;
              text-align: right;
              .e-d-n1{
                font-size: 20px;
                color: #79d8ff;
                font-family: Bahnschrift;
              }

            }
          }

        }
      }

    }
  }
</style>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue是一种流行的JavaScript框架,用于构建用户界面。ECharts是一种用于创建交互性和可视化图表的图表库。在生产环境中,可以使用VueECharts来创建一个生产任务看板。 首先,我们可以使用Vue框架来构建用户界面。通过Vue的组件化架构,我们可以将任务看板拆分为多个可重用的组件,例如任务列表、进度条、功能按钮等。这样可以使代码更可维护和可扩展。同时,Vue提供了响应式的数据绑定机制,可以实时更新任务看板的数据,并与后端进行数据交互。 然后,我们可以使用ECharts图表库来创建可视化图表,以展示任务看板上的数据。例如,可以使用饼图来显示任务的进度分布,柱状图来展示各个任务的完成情况,折线图来展示任务的趋势等。ECharts提供了丰富的图表类型和交互功能,可以根据实际需求进行灵活配置。 在整个过程中,我们可以利用Vue的生命周期钩子函数来实现数据的获取、更新和渲染。当用户发起操作时,可以通过Vue的事件机制来触发相应的业务逻辑。例如,当用户点击任务列表中的某个任务时,可以发送请求获取该任务的详细信息,并在界面上展示出来。 最后,为了提高用户体验,我们可以将任务看板进行排版和样式的优化,使其在不同设备和浏览器上都能良好展示。同时,可以增加一些交互功能,例如拖拽任务、快速搜索任务等,以提高用户的生产效率。 总结而言,通过使用VueECharts,我们可以实现一个功能齐全、交互性强的生产任务看板。它可以直观展示任务的状态和进度,并提供方便的操作和管理功能,帮助用户更好地进行生产任务的监控和调度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值