<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts'

import { onMounted, ref } from 'vue'

import { EchartsUI, useEcharts } from '@vben/plugins/echarts'

const props = defineProps({
  chartDetail: {
    type: Object,
    default: () => {},
  },
})
const chartRef = ref<EchartsUIType>()
const { renderEcharts } = useEcharts(chartRef)

onMounted(() => {
  renderEcharts({
    series: [
      {
        animationDelay() {
          return Math.random() * 400
        },
        animationEasing: 'exponentialInOut',
        animationType: 'scale',
        center: ['50%', '50%'],
        color: ['#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9'],
        data: [
          { name: '优秀学生数', value: props.chartDetail?.level1Count || 0 },
          { name: '良好学生数', value: props.chartDetail?.level2Count || 0 },
          { name: '及格学生数', value: props.chartDetail?.level3Count || 0 },
          { name: '不及格学生数', value: props.chartDetail?.level4Count || 0 },
          // { name: '远程', value: props.chartDetail?.remoteCount || 0 },
        ].sort((a, b) => {
          return a.value - b.value
        }),
        name: '提交情况',
        radius: '80%',
        roseType: 'radius',
        type: 'pie',
      },
    ],

    tooltip: {
      trigger: 'item',
    },
  })
})
</script>

<template>
  <EchartsUI ref="chartRef" />
</template>
