<template>
  <div>
    <div id="bkfx"></div>
  </div>
</template>
<script>
import * as echarts from 'echarts';
import { bkfxchartInfo } from "../../../servuces/prove";
export default {
  data () {
    return {
      bkfxdata: []
    }
  },
  mounted () {
    this.bkfxchartapi()
  },
  methods: {
    chart5 () {
      const bkfx = document.getElementById('bkfx');
      const myChart5 = echarts.init(bkfx);
      const option5 = {
        title: {
          top: '10%',
          left: 'center',
          textStyle: {
            fontSize: 22,//字体大小
            color: 'white'//字体颜色
          },

        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          left: '30%',
          textStyle: {
            fontSize: 12,//字体大小
            color: 'white'//字体颜色
          },
        },
        series: [
          {
            type: 'pie',
            radius: '60%',
            label: {
              fontSize: 16,
              color: 'white',
              show: true,
              formatter (param) {
                // correct the percentage
                return param.name + ' (' + param.percent * 2 + '%)';
              }
            },
            data: this.bkfxdata,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      option5 && myChart5.setOption(option5);
    },
    bkfxchartapi () {
      bkfxchartInfo().then(res => {
        this.bkfxdata = res.data
        console.log(res.data);
        this.chart5()
      })
    }
  }
}
</script>
<style scoped>
#bkfx {
  width: 100%;
  height: 500px;
  margin: 0 auto;
}
</style>