<template>
  <div style="height: 80vh; width: 800px;">
    <div class="echart-box-hot">
      <Map
        ref="hotmap"
        :table-headers="TABLEHEADER['1']"
        download-name="中国地图"
        :customer-battery-city-data-props="customerBatteryCityData"
        :callback="hanlderEchartCallback"
        :map-area-color="areaColor"
        :map-border-color="borderColor"
        @cellClick="handlerCellClick"
      >
        <span>中国地图</span>
      </Map>
    </div>
  </div>
</template>

<script>
import { HotMap as Map } from '@p/index.js'
import TABLEHEADER from '@u/echartTableHeader.js'
export default {
  name: 'MapPage',
  components: {
    Map
  },
  data() {
    return {
      TABLEHEADER: TABLEHEADER,
      customerBatteryCityData: [],
      areaColor: '#0c274b',
      borderColor: '#1cccff'

    }
  },
  mounted() {
    this.$refs.hotmap.initChart('中国')

    setTimeout(() => {
      this.customerBatteryCityData = [
        { name: '北京', value: 70 },
        { name: '天津', value: 20 },
        { name: '陕西', value: 70 },
        { name: '河南', value: 70 },
        { name: '新疆', value: 7000 }
      ]
    }, 1000)
    // setTimeout(() => {
    //   this.customerBatteryCityData = [
    //     { name: '海淀区', value: 170 },
    //     { name: '朝阳区', value: 20 },
    //     { name: '东城区', value: 300 }
    //   ]
    // }, 3000)

    // setTimeout(() => {
    //   this.customerBatteryCityData = []
    // }, 6000)

    // setTimeout(() => {
    //   this.customerBatteryCityData = [
    //     { name: '阳江市', value: 70 },
    //     { name: '茂名市', value: 20 },
    //     { name: '广州市', value: 70 },
    //     { name: '河源市', value: 70 },
    //     { name: '湛江市', value: 120 },
    //     { name: '潮州市', value: 70 },
    //     { name: '东莞市', value: 70 }
    //   ]
    //   this.$refs.hotmap.initChart('广东')

    //   this.$nextTick(() => {
    //     this.$refs.hotmap.initBar()
    //   })
    // }, 5000)

    // this.$refs.hotmap.initBar(customerBatteryCityData)
  },
  methods: {
    hanlderEchartCallback(params) {
      this.customerBatteryCityData = [

        //   { name: '北京市', value: 70 },
        //   { name: '天津市', value: 20 },
        //   { name: '陕西省', value: 70 },
        //   { name: '河南省', value: 70 }

        //   // { name: '阳江市', value: 70 },
        // { name: '茂名市', value: 20 },
        // { name: '广州市', value: 70 },
        // { name: '河源市', value: 70 },
        // { name: '湛江市', value: 120 }
        // { name: '潮州市', value: 70 },
        { name: '东莞市', value: 70 },
        { name: '深圳市', value: 0 },
        { name: '清远市', value: 70 },
        { name: '韶关市', value: 10 },
        { name: '云浮市', value: 70 },
        { name: '惠州市', value: 150 },
        { name: '汕头市', value: 60 },
        { name: '揭阳市', value: 80 },
        { name: '中山市', value: 70 },
        { name: '肇庆市', value: 70 },
        { name: '珠海市', value: 12000 },
        { name: '汕尾市', value: 0 },
        { name: '江门市', value: 70 },
        { name: '梅州市', value: 70 },
        { name: '佛山市', value: 10 }
      ]
      if (params.seriesType === 'map') {
        alert('点击的是地图')
      } else {
        alert('点击的是柱子')
      }
      if (params.name) {
        this.$refs.hotmap.initChart(params.name, true)
        this.$nextTick(() => {
          this.$refs.hotmap.initBar()
        })
      } else {
        return
      }
    },
    handlerCellClick(params) {
      // 表格跳转 row, column  横纵参数需求什么自己拿什么
      console.log(params)
    }
  }
}
</script>

<style>
.echart-box-hot {
  height: 100%;
  width: 100%;
  margin: 0 auto;
  margin-bottom: 20px;
}
</style>
