react 中echarts-for-react使用resize解決圖表自適應問題

webnote發表於2024-03-25

import React, { PureComponent } from "react";
import ReactEcharts from 'echarts-for-react';
import { useEventListener } from 'ahooks';

  useEventListener(
    'resize',
    () => {
        ref?.current?.getEchartsInstance()?.reresize;
    },
    
  );

 return (
            <ReactEcharts
              ref={ref}
              option={pieOption(distributionData?.parentModelInfoList || [], {})}
              style={{
                height: '320px',
                width: clientWidth,
              }}
            />
  );

相關文章