<template>
  <div  :class="className" :style="{height:height,width:width}" />
</template>
<script>
  import echarts from 'echarts'
  require('echarts/theme/macarons') // echarts theme
  //import resize from './mixins/resize'

  const animationDuration = 4200
  export default {
    // mixins: [resize],
    props: {
      className: {
        type: String,
        default: 'chart'
      },
      width: {
        type: String,
        default: '100%'
      },
      height: {
        type: String,
        default: (window.innerHeight-260)+"px"
      },
      autoResize: {
        type: Boolean,
        default: true
      },

    },
    data() {
      return {
        chart: null
      }
    },
    methods: {
      initChart() {
        this.chart = echarts.init(this.$el, 'macarons')

        this.chart.setOption({
          legend: {},
          tooltip: {},
          dataset: {
            dimensions: ['product', '案卷数', '原文数'],
            source: [
              { product: '传统文书', '案卷数': 27, '原文数': 17, },
              { product: '会计凭证', '案卷数': 1, '原文数': 2, },
              { product: '录像', '案卷数': 0, '原文数': 0, },
              { product: '音像', '案卷数': 2, '原文数': 3, },
              { product: '照片', '案卷数': 5, '原文数': 12, },
              { product: '印章', '案卷数': 11, '原文数': 29, },
              { product: '磁盘', '案卷数': 0, '原文数': 0, },
              { product: '光盘', '案卷数': 0, '原文数': 0, },
              { product: '磁带', '案卷数': 23, '原文数': 10, },
            ]
          },
          xAxis: { type: 'category' },
          yAxis: {},
          series: [{ type: 'bar' }, { type: 'bar' }]
        })
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.initChart()
      })
    },
    beforeDestroy() {
      if (!this.chart) {
        return
      }
      this.chart.dispose()
      this.chart = null
    },
  }

</script>
