You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Adamatoma (via GitHub)" <gi...@apache.org> on 2024/05/07 04:08:33 UTC

Re: [I] Prevent overlap of grid and legend [echarts]

Adamatoma commented on issue #14252:
URL: https://github.com/apache/echarts/issues/14252#issuecomment-2097407087

   Hi everyone, 
   I found a proper way after looked through all the issues and solutions refer to the "legend overlap element" problems.
   This solution leads to an ideal direction: https://github.com/lightdash/lightdash/issues/541#issuecomment-1157815376
   And here's my final version:
   ```
   const [legendHeight, setLegendHeight] = useState(0);
   useDebounceEffect(
       () => {
           if (chartRef.current) {
               // @ts-ignore
               const found = chartRef.current._componentsViews.find((entry: any) => entry.type === 'legend.plain');
               const myLegendHeight = found?._backgroundEl.shape.height;
               chartRef.current.setOption({
                   grid: {top: myLegendHeight},
               });
           }
       },
       [window_size.width],
       {wait: 200}
   );
   ```
   
   Cheers!


-- 
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