<template>
  <div class="Echarts">
    <div id="main" style="width:100%; height:600px;"></div>
  </div>
</template>

<script>
  require('echarts/lib/component/legend')
  export default {
    name: 'Echarts',
    methods: {
      myEcharts() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = this.$echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
          title: {
            text: '到资金额柱状图',
            top: 0,
            left: 'center',
            subtextStyle: {
              fontFamily: "微软雅黑",
              fontSize: 14,
              color: '#6c7a89',
            }
          },
          tooltip: {},
          legend: {
            data: ['到账金额'],
            top: 25,
          },
          xAxis: {
            data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
          },
          yAxis: {},
          series: [{
            name: '到账金额',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20],
            itemStyle: {
              normal: {
                color: '#1C84C6', //设置柱子颜色
                label: {
                  show: true, //柱子上显示值
                  position: 'top', //值在柱子上方显示
                  textStyle: {
                    color: '#333' //值得颜色
                  }
                }
              }
            },
          }]
        };

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

<style>

</style>
