You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2022/04/28 02:28:00 UTC

[GitHub] [echarts] xmdong commented on issue #16912: [Question]图例可能会有多行时,如何避免图形与图例重叠?

xmdong commented on issue #16912:
URL: https://github.com/apache/echarts/issues/16912#issuecomment-1111672755

   目前我的解决方法如下(使用react hooks)
   `const [legendHeight, setLegendHeight] = useState<number>(0);`
   
   `const onChartFinished = useCallback((a: any, instance: EChartsInstance) => {
         const legendModel = instance.getModel().getComponent("legend");
         const legendView = instance.getViewOfComponentModel(legendModel);
         const { height } = legendView.group.getBoundingRect();
         setLegendHeight(height);
       }, []);`
   
   `return (
         <ReactECharts
           style={{ height: `${legendHeight + 220}px`, width: "100%" }}
           option={option}
           onEvents={{
             finished: onChartFinished,
           }}
         />
       );`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org