<!--Echart基本架構-->
<template>
  <div id="box" ></div>
</template>

<script>
export default {
  name: "BasicBar",
  data() {
    return {
      mockdata:{
        xAxisData:["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], // x轴数据
        barNumData:[5, 20, 36, 10, 10, 20]// y轴条状高度数据
      }
    };
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      //基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("box")); //绘制图表
      myChart.setOption({
        tooltip: {}, // 悬停效果
        xAxis: {
          axisLabel: {
            color: "yellow",
          },
          data: this.mockdata.xAxisData
        },
        yAxis: {}, //  y轴数据
        series: [
          {
            name: "销量",
            type: "bar", // 条状
            data: this.mockdata.barNumData, // y轴数据
          },
        ],
      });
    },
  },
};
</script>

<style>
#box{
  width: 500px;
  height: 500px;
}
</style>
