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

export default {
  mixins: [resize],
  data() {
    return {
      chart: null,
      //检查类型
      examtype: [],
      nameList : [],
    };
  },
   created(){
      },
  mounted() {
  this.selectexamtype();
  },
  beforeMount(){
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initData(){
     
    },
     selectexamtype(){
      historyVisittType().then((response) =>{
      // console.log("历史不同就诊类型");
      // console.log(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
          }
        ]
      });
      // console.log(that.nameList)
    }
  }
};
</script>
