<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div id="myChart" :style="{width: '100%', height: '300px'}"></div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  data () {
    return {
      userTotal: 0
    }
  },
  props: ['materialChartList'],
  mounted () {
    this.drawLine()
  },
  methods: {
    drawLine () {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('myChart'))
      // 绘制图表
      myChart.setOption({
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['图文总阅读人数', '图文总阅读次数']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: [
            '2016-1',
            '2016-2',
            '2016-3',
            '2016-4',
            '2016-5',
            '2016-6',
            '2016-7',
            '2016-8',
            '2016-9',
            '2016-10',
            '2016-11',
            '2016-12'
          ]
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '图文总阅读人数',
            type: 'line',
            stack: '总量',
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '图文总阅读次数',
            type: 'line',
            stack: '总量',
            data: [220, 182, 191, 234, 290, 330, 310]
          }
        ]
      })
    }
  }
}
</script>
