wujingjing
2024-11-12 545109f5b8fe240cb12ea613fc58aec1551b1b09
src/components/chat/chatComponents/hooks/useDrawChatChart.ts
@@ -16,25 +16,30 @@
      resizeChart?.(width, height);
   };
   const initChart = ()=>{
   const initChart = () => {
      setTimeout(() => {
         const parent = chartRef.value.parentElement;
         const parentBound = parent.getBoundingClientRect();
         chartInstance.value = echarts.init(chartRef.value, undefined, {
            width: parentBound.width,
            height: parentBound.height,
            locale: 'ZH',
         });
         resizeChart = debounce((width, height) => {
            chartInstance.value.resize({
               width: width,
               height: height,
         const instance = echarts.getInstanceByDom(chartRef.value);
         if (!instance) {
            const parent = chartRef.value.parentElement;
            const parentBound = parent.getBoundingClientRect();
            chartInstance.value = echarts.init(chartRef.value, undefined, {
               width: parentBound.width,
               height: parentBound.height,
               locale: 'ZH',
            });
         });
            resizeChart = debounce((width, height) => {
               chartInstance.value.resize({
                  width: width,
                  height: height,
               });
            });
         }
         drawChart();
      }, 100);
   }
   };
   onMounted(() => {
      initChart();
@@ -43,5 +48,6 @@
   return {
      chartContainerResize,
      chartInstance,
   };
};