<template>
  <ve-pie :data="chartData" :extend="extend" :title="title"/>
</template>

<script>
import { wellStaticByBfzt } from '@/api/dataStatics'
export default {
  data() {
    this.extend = {
      series: {
        label: { show: true, position: 'outside', formatter: '{b}:{c}' }
      }
    }
    this.chartSettings = {
      labelMap: {
        'bfzt': '布防状态',
        'wellCount': '井数量'
      },
      dimension: 'bfzt',
      metrics: 'wellCount'
    }
    this.title = {
      text: '布防撤防统计'
    }
    return {
      chartData: {
        columns: ['bfzt', 'wellCount'],
        rows: []
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  activated() {
    this.fetchData()
  },
  methods: {
    // 获取统计数据
    fetchData() {
      wellStaticByBfzt(this.listQuery).then(response => {
        const data = response.data
        this.chartData.rows = [
          { 'bfzt': '布防', 'wellCount': data.bfWell },
          { 'bfzt': '撤防', 'wellCount': data.cfWell }
        ]
      })
    }
  }
}
</script>
