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

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

const props = defineProps({
  defaultOption: Object
});


const chart = ref(null);
const option = ref(null);
const chartRef = ref();

const setData = (e) => {
  option.value = e;
  initChart(e);
};
const initChart = (option) => {
  if (!chart.value) {
    chart.value = echarts.init(chartRef.value, 'macarons');
  }
  chart.value.setOption(option, true);
};

defineExpose({
  setData
});
</script>
