From da478531b25b04c4442084625a4eca6ded76c448 Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Wed, 17 Feb 2021 02:37:35 +0100 Subject: [PATCH] Fix chart panel overflowing (#13154) --- .../explore/components/ExploreChartPanel.jsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/explore/components/ExploreChartPanel.jsx b/superset-frontend/src/explore/components/ExploreChartPanel.jsx index 6962dfa2861..61916984d7f 100644 --- a/superset-frontend/src/explore/components/ExploreChartPanel.jsx +++ b/superset-frontend/src/explore/components/ExploreChartPanel.jsx @@ -118,7 +118,7 @@ const ExploreChartPanel = props => { refreshMode: 'debounce', refreshRate: 300, }); - const { width: chartWidth, ref: chartRef } = useResizeDetector({ + const { width: chartPanelWidth, ref: chartPanelRef } = useResizeDetector({ refreshMode: 'debounce', refreshRate: 300, }); @@ -183,6 +183,7 @@ const ExploreChartPanel = props => { const renderChart = useCallback(() => { const { chart } = props; const newHeight = calcSectionHeight(splitSizes[0]) - CHART_PANEL_PADDING; + const chartWidth = chartPanelWidth - CHART_PANEL_PADDING; return ( chartWidth > 0 && ( { /> ) ); - }, [calcSectionHeight, chartWidth, props, splitSizes]); + }, [calcSectionHeight, chartPanelWidth, props, splitSizes]); const panelBody = useMemo( - () =>
{renderChart()}
, - [renderChart], + () => ( +
+ {renderChart()} +
+ ), + [chartPanelRef, renderChart], ); const standaloneChartBody = useMemo( - () =>
{renderChart()}
, - [chartRef, renderChart], + () =>
{renderChart()}
, + [chartPanelRef, renderChart], ); if (props.standalone) { @@ -252,7 +257,7 @@ const ExploreChartPanel = props => { }); return ( - +
{header}