<template>
  <div class="char" id="barcircle">

  </div>
</template>

<script setup>
import * as echarts from "echarts";
import { ref, onMounted, watch, defineProps } from "vue";
const props = defineProps({
  key: Number,
  serData: { type: Array },
  yAxdata: { type: Array }
});
watch(
  () => props.key,
  () => {
    lineChartFn();
  },
  {
    deep: true
  }
);
function lineChartFn() {
  var chartDom = document.getElementById("barcircle");
  var myChart = echarts.init(chartDom);
  var option;

  option = {
    backgroundColor: "rgba(0,0,0,0)",

    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow"
      }
    },
    legend: {},
    grid: {
      top: "10%",
      left: "3%",
      right: "4%",
      bottom: "8%",
      containLabel: true
    },
    xAxis: {
      type: "category",
      data: props.yAxdata
    },
    yAxis: {
      type: "value",
      boundaryGap: [0, 0.01]
    },
    series: props.serData
  };
  option && myChart.setOption(option);
  window.onresize = function () {
    myChart.resize();
  };
  document.getElementById("barcircle").setAttribute("_echarts_instance_", "");
}
onMounted(() => {
  lineChartFn();
});
</script>

<style lang="scss" scoped>
.char {
  width: 100%;
    height: 300px;
}

.canvas {
  height: 320px !important;
  background-color: none !important;
}
</style>
