<template>
  <!--<div class="chartCont">-->
    <div style="width:90%">
      <IEcharts :option="option" style="width:100%;height: 238px"></IEcharts>
    </div>
  <!--</div>-->
</template>

<script>
export default {
  components: {},
  data() {
    return {
      option: {
        color: this.$echartColor,
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
          x: 130
        },
        xAxis: [
          {
            type: 'category',
            data: [],
            axisPointer: {
              type: ''
            },
            axisLine: {
              lineStyle: {
                color: 'gray'
              }
            },
            splitLine: { show: false }
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '检测量',
            min: 0,
            axisLabel: {
              formatter: '{value}'
            },
            axisLine: {
              lineStyle: {
                color: 'gray'
              }
            },
            splitLine: { show: false }
          }
        ],
        series: [
          {
            name: '检测量',
            type: 'bar',
            data: []
          }
        ]
      },

      year: ''
    }
  },
  methods: {
    _openBar: function(obj) {
      this.option.series[0].data = []
      this.option.xAxis[0].data = []
      this.option.xAxis[0].data = obj.mounth
      this.option.series[0].data = obj.num
      // this.year = obj.date.getFullYear()
      // this.groupId = obj.groupId
      // this.option.xAxis[0].data = []
      // for (let i = 1; i < 13; i++) {
      //   if (i < 10) {
      //     this.option.xAxis[0].data.push(this.year + '-0' + i)
      //   } else {
      //     this.option.xAxis[0].data.push(this.year + '-' + i)
      //   }
      // }
      // this.$store
      //   .dispatch('FoodContract/groupYearNum', {
      //     year: this.year,
      //     groupId: this.groupId
      //   })
      //   .then(() => {
      //     const result = this.$store.state.FoodContract.page
      //     this.option.series[0].data = []
      //     for (let j = 0; j < result.length; j++) {
      //       for (let k = 0; k < this.option.xAxis[0].data.length; k++) {
      //         if (result[j].testMonth === this.option.xAxis[0].data[k]) {
      //           this.option.series[0].data[k] = result[j].testCount
      //         }
      //       }
      //     }
      //   })
    }
  }
}
</script>
