<template>
  <div :id="props.ids" style="width: 100%; height: 100%"></div>
</template>

<script setup>
import { ref, onMounted } from "vue";
//  按需引入 echarts
import * as echarts from "echarts";
const props = defineProps({
  ids: {
    type: String,
    default: "mian"
  },
  Xdata: {
    type: Array,
    default: []
  },
  serData: {
    type: Array,
    default: []
  }
});
onMounted(() => {

  init(props.Xdata, props.serData);
});
function init(Xdata, serData) {
  // 基于准备好的dom，初始化echarts实例
  var myChart = echarts.init(document.getElementById(props.ids));
  // 指定图表的配置项和数据
  var option = {
    tooltip: {},
    legend: {
      show: false
    },
    xAxis: {
      data: Xdata
    },
    yAxis: {},
    series: [
      {
        data: serData,
        type: 'bar',
        itemStyle: {
          normal: {
            label: {
              show: true,
              position: 'top'
            }
          }
        }
      },
      {
        data: serData,
        type: 'line'
      }

    ]
  };
  // 使用刚指定的配置项和数据显示图表。
  myChart.setOption(option);
}
</script>

<style lang="scss" scoped>
.SectorDiagram {
  width: 100%;
  height: 100%;
}
</style>
