<template>
  <ve-bar :data="chartData" :grid="grid" :title="title" :extend="extend" :settings="chartSettings"/>
</template>

<script>
// 引入视觉映射组件
import 'echarts/lib/component/visualMap'
import { wellStaticByType } from '@/api/dataStatics'

export default {
  data() {
    this.extend = {
      series: {
        label: { show: true, position: 'right' }
      }
    }
    this.grid = {
      right: 60
    }
    this.title = {
      text: '井类型数量统计'
    }
    this.chartSettings = {
      itemStyle: {
        'barCategoryGap': 5
      },
      barWidth: 15,
      labelMap: {
        'wellTypeName': '井类型',
        'wellCount': '井数量'
      },
      dimension: ['wellTypeName'],
      metrics: ['wellCount']
    }
    return {
      chartData: {
        columns: ['wellTypeName', 'wellCount'],
        rows: []
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  activated() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      wellStaticByType().then(response => {
        this.chartData.rows = response.data
      })
    }
  }
}
</script>
