// 绘制echarts图表
import * as echarts from 'echarts'
import 'echarts-wordcloud';
const setChart = (option, chartId) => {
  let chartDom = document.getElementById(chartId);
  if (!chartDom) {
    return null;
  }
  chartDom.removeAttribute("_echarts_instance_");
  let chart = echarts.init(chartDom);
  chart.setOption(option);
  // 容器可能受布局/异步渲染影响，强制一次 resize 保证 canvas 与容器一致
  setTimeout(() => {
    chart.resize();
  }, 0);
  return chart;
};

export default setChart