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