<template>
  <div  id="main" :style="{ height: '100%', width: '100%' }" />
</template>

<script>
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "./mixins/resize";
import { ExamType } from "@/api/system/PaneIGroup";

export default {
  mixins: [resize],
  data() {
    return {
      chart: null,
      //检查类型
      examtype: [],
      nameList : [],
    };
  },
   created(){
      this.selectexamtype();
      },
  mounted() {
  
  },
  beforeMount(){
   
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initData(){
     
    },
     selectexamtype(){
      ExamType().then((response) =>{
      let that=this;
      var arr;
      that.examtype=[];
      that.nameList =[];
     response.data.forEach(item => {
       that.examtype.push(item);
       that.nameList.push(item.name);
     });
       this.$nextTick(() => {
      this.initChart();
    });
    })
     },
    initChart() {
      this.chart = echarts.init(this.$el, "macarons");
      this.chart.setOption({
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          left: "center",
          bottom: "10",
          data: this.nameList
        },
        series: [
          {
            name: "历史不同检查类型预约",
            type: "pie",
            roseType: "radius",
            radius: [15, 95],
            center: ["50%", "38%"],
           data: this.examtype,
            animationEasing: "cubicInOut",
            animationDuration: 2600
          }
        ]
      });     
    }
  }
};
</script>
