<template>
  <div id="binline" style="width: 100%; height: 100%"></div>
</template>


<script setup>
import * as echarts from "echarts";

import {
  ref,
  defineProps,
  reactive,
  onMounted,
  watch,
  defineExpose,
  nextTick
} from "vue";
import { chartAdaptation } from "@/utils/tools";
//   import { deepClone } from "@/utils/tools";
const props = defineProps({
  barNum: {
    type: Array,
    default: []
  },
  barTitle: {
    type: Array,
    default: []
  },

});
onMounted(() => {
  // nextTick(() => {
  //   if (props.loadingshow) {
  //     getBin(props.barTitle, props.barNum);

  //   }
  // });
  getBin(props.barTitle, props.barNum);
});
const getBin = (data, twodata) => {
  const chartDom = document.getElementById("binline");
  var myChart = echarts.init(chartDom);
  var option;

  option = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        crossStyle: {
          color: '#999'
        }
      }
    },
    legend: {
      data: ['培训数量'],
      textStyle: {
        color: '#319177'
      }
    },
    xAxis: [
      {
        type: 'category',
        data: data,
        axisPointer: {
          type: 'shadow'
        },
        axisLine: {
          lineStyle: {
            color: "#319177"
          }
        }

      },

    ],
    yAxis: [
      {
        type: 'value',
        name: '培训数量',
        axisLabel: {
          formatter: '{value} '
        },
        axisLine: {
          lineStyle: {
            color: "#07c8bd"
          }
        },

      }
    ],
    series: [
      {
        name: '培训数量',
        type: 'bar',
        tooltip: {
          valueFormatter: function (value) {
            return value;
          }
        },
        data: twodata,
        itemStyle: {
          normal: {
            color: '#319177'
          }
        },
      }
    ]
  };

  option && myChart.setOption(option);
  //自适应
  chartAdaptation(myChart);
};
// defineExpose({ getBin });
</script>
<style scoped></style>

