react 中echarts-for-react使用resize解决图表自适应问题

 

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,
              }}
            />
  );

 

posted @ 2024-03-25 17:08  webnote  阅读(276)  评论(0编辑  收藏  举报