
<template>
  <div style="height: 360px" id="dtdcChart"/>
</template>

<style scoped lang="scss"></style>
<script>
import * as echarts from 'echarts'
import resize from '@/mixins/ems/resize'

export default {
  mixins: [resize],
  data() {
    return {
      chart: null
    }
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(document.querySelector('#dtdcChart'))
    },
    setOption() {
      const source = [['日期','电压','温度','SOC','SOH']]
      source.push(['1月','12','13','14','15'],['2月','12','13','14','15'])
      this.chart.setOption({
        color:['#FFBD00','#3C81FF','#05AEA3','#F86F70'],
        legend: {
          bottom: '10',
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: { // 坐标轴指示器，坐标轴触发有效
            type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        textStyle:{
          color:"#333333",
        },
        xAxis: {
          type: 'category',
        },
        yAxis: {
          type: 'value',
        },
        dataset:{
          source
          // source: [['日期','充电量','放电量']]
        },
        series: [
          {
            name:'电压',
            type: 'bar',

          },{
            name:'温度',
            type: 'bar',
          },
          {
            name:'SOC',
            type: 'bar',

          },{
            name:'SOH',
            type: 'bar',
          }]
      })
    }
  },
  mounted() {
    this.initChart()
  }
}

</script>
