<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 { TedayExamType } from "@/api/system/PaneIGroup";

export default {
  mixins: [resize],
  data() {
    return {
      chart: null,
      //检查类型
      examtype: [],
      nameList : [],
      typenum:[
                {value: 1, name: '超声'},
                {value: 1, name: '胃镜'},
                {value: 1, name: '放射'},
                {value: 1, name: 'CT'},
                {value: 1, name: '心电图'}
      ],
      typename: ["超声", "胃镜","放射","CT","心电图"]
    };
  },
   created(){
      },
  mounted() {
  this.selectexamtype();
  },
  beforeMount(){
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initData(){
     
    },
     selectexamtype(){
      TedayExamType().then((response) =>{
      // console.log("今日不同检查类型预约");
      let that=this;
      that.examtype=[];
      that.nameList =[];
     response.data.forEach(item => {
       if(response.data !=null && response.data.length>0){
       that.examtype.push(item);
       that.nameList.push(item.name);
       }else{
         this.typename.forEach((res) =>{
           this.nameList.push(res);
         })
         this.typenum.forEach((ele) => {
           this.examtype.push(ele);
         })
       }
      
        
     });
    //  console.log(this.typenum);
    //  console.log(this.typename);
    //页面初始化
      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>
