<template>
  <div id="card-4">
    <el-row>
      <el-col :span="24" class="main">
        <div id="card_fou" style="width: 100%; height: 17vw"></div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import * as echarts from 'echarts';
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'index',
  props: {},
  components: {},
  data: function () {
    return {};
  },
  computed: {
    ...mapState(['user']),
  },
  mounted() {
    this.getEchartData();
  },
  created() {},
  methods: {
    getEchartData() {
      var chartDom = document.getElementById('card_fou');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: '商品销量对比',
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        legend: {},
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01],
        },
        yAxis: {
          type: 'category',
          data: ['商品一', '商品二', '商品三', '商品四', '商品五', '商品六'],
        },
        series: [
          {
            name: '本月',
            type: 'bar',
            data: [122, 45, 78, 233, 56, 75],
          },
          {
            name: '上月',
            type: 'bar',
            data: [234, 134, 54, 27, 145, 87],
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped></style>
