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

<script>
import * as echarts from 'echarts';

export default {
  expose: ['setData'],
  data() {
    return {
      chart: null,
      chartOption: {}
    }
  },
  mounted() {

  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    setData(option) {
      this.chartOption = option
      this.initChart(option)
    },
    initChart(option) {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption(option)
    }
  }
}
</script>
