<template>
  <div />
</template>

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

export default {
  expose: ['setData', 'getChart'],
  data() {
    return {
      chart: null,
    }
  },
  mounted() {
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    setData(option) {
      this.initChart(option)
    },
    initChart(option) {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption(option)
    },
    getChart() {
      return this.chart
    }
  }
}
</script>
