<template>
  <div ref="dsChartRef" :style="{ height, width }"></div>
</template>
<script lang="ts">
import { PropType, Ref, defineComponent, onMounted, ref } from 'vue';
import { queryDomainScore } from '../StProjectStaticsChart.api';
import { useECharts } from '/@/hooks/web/useECharts';

export default defineComponent({
  props: {
    width: {
      type: String as PropType<string>,
      default: '100%',
    },
    height: {
      type: String as PropType<string>,
      default: 'calc(100vh - 250px)',
    },
    depId:{
      type:String as PropType<string>,  
    }
  },
  setup(props) {
    const dsChartRef = ref<HTMLDivElement | null>(null);
    const { setOptions } = useECharts(dsChartRef as Ref<HTMLDivElement>);
    onMounted(() => {
      queryDomainScore({}).then(rep=>{
        if(!rep || rep.names==null||rep.names.length==0){
          return
        }
        setOptions({
          title: {
          text: ''
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          show: false,
        },
        grid: {
          top:'3%',
          left: '15%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01]
        },
        yAxis: {
          type: 'category',
          data: rep.names||[]
        },
        series: [
          {
            type: 'bar',
            data: rep.scores||[]
          }
        ]
        })
      })
    })
    return { dsChartRef }
  },
})
</script>
