<template>
  <div>
    <div id="bottomRightBar" style="width: 9rem;height: 3rem;"></div>
  </div>
</template>

<script>
import echartMixins from "@/utils/resizeMixins";
export default {
  data() {
    return {
      chart: null
    };
  },
  mixins: [echartMixins],
  mounted() {},
  methods: {
    draw(data) {
      // 基于准备好的dom，初始化echarts实例
      this.chart = this.$echarts.init(document.getElementById("bottomRightBar"));
      const labelOption = {
        show: true,
        position: 'insideBottom',
        distance: '15',
        align: 'left',
        verticalAlign: 'middle',
        rotate: '90',
        fontSize: 14,
        rich: {
          name: {}
        }
      };
      let option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        color: [ '#54cce2', '#1fd7fd', '#8aa4fa', '#93fd8b'],
        legend: {
          data: ['Forest', 'Steppe', 'Desert', 'Wetland'],
          textStyle: {
            color: '#fff'  
          }
        },
        toolbox: {
          show: true,
          itemSize: 20,
          itemGap: 30,
          showTitle: false,
          orient: 'vertical',
          left: 'right',
          top: 'center',
          iconStyle :{
            color: '#fff'
          }, 
          feature: {
            magicType: { show: true, type: [ 'bar', 'stack'] },
          }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            axisTick: { show: false },
            data: data.nameList,
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff',  //更改坐标轴文字颜色
                fontSize : 16      //更改坐标轴文字大小
              }
            },
            axisLine:{
              lineStyle: {
                color:'#fff' //更改坐标轴颜色
              }
            }
          }
        ],
        yAxis: [{
          type: 'value',
          splitLine: { show: false },
          axisLabel: {
            show: true,
            textStyle: {
            color: '#fff',  //更改坐标轴文字颜色
            fontSize : 16      //更改坐标轴文字大小
            }
          },
          axisLine:{
            lineStyle: {
              color:'#fff' //更改坐标轴颜色
            }
          }
        }],
        series: [
          {
            name: '工作垛位',
            type: 'bar',
            barGap: 0,
            label: labelOption,
            emphasis: {
              focus: 'series'
            },
            data: data.aisleList[0],
          },
          {
            name: '有货垛位',
            type: 'bar',
            label: labelOption,
            emphasis: {
              focus: 'series'
            },
            data: data.aisleList[1]
          },
          {
            name: '无货垛位',
            type: 'bar',
            label: labelOption,
            emphasis: {
              focus: 'series'
            },
            data: data.aisleList[2]
          }
        ]
      };
      this.chart.setOption(option);
    }
  },
  destroyed() {
    window.onresize = null;
  }
};
</script>

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