<template>
  <div id="chartDl" style="width: 100%; height: 100%"></div>
</template>

<script>
export default {
  name: "ChartDl",
  data() {
    return {
      myChart: null
    }
  },
  methods: {
    init() {
      let dataAxis = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月', '测试月'];
      let start = dataAxis.length - 12;
      let end = dataAxis.length - 1;
      let options = {
        tooltip: {
          trigger: 'axis',
        },
        color: ['#49A9EE'],
        dataZoom: [{
          type: 'inside',
          startValue: start,
          endValue: end,
          show: false
          // zoomOnMouseWheel: false,
          // zoomLock: true,
        }],
        // dataZoom: [
        //
        //   {
        //     type: 'slider',
        //     startValue: start,
        //     endValue:end,
        //     zoomOnMouseWheel: false,
        //     zoomLock: true,
        //   },
        //   {
        //     type: 'inside'
        //   },
        // ],
        xAxis: [
          {
            type: 'category',
            data: dataAxis,
            axisPointer: {
              type: 'shadow'
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: '#6e7079',
              }
            },
            axisTick:{
              show:false
            },
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '电量统计情况',
            axisLabel: {
              formatter: '{value} KW·h'
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: '#6e7079',
              }
            },
            axisTick:{
              show:false
            },
          }
        ],
        series: [
          {
            name: '电量',
            type: 'line',
            // stack: 'Total',
            smooth: true,
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            itemStyle : {
              color:'#73C0DE',
              borderColor:"#a3c8d8",
              normal: {
                label : {
                  show: true,
                  textStyle: {
                    fontSize: 14
                  }
                }
              }
            },
            data: [120, 132, 101, 134, 90, 230, 210, 210, 245, 203, 124, 214, 210]
          }
        ]
      }
      this.myChart.setOption(options)
    }
  },
  mounted() {
    this.myChart = this.$echarts.init(document.getElementById('chartDl'));
    this.init()
  }
}
</script>

<style scoped>

</style>
