From d1b017c8b6014c33b6ff96941c9866c3be4fb1d7 Mon Sep 17 00:00:00 2001 From: islxyqwe Date: Wed, 28 Aug 2024 16:48:23 +0800 Subject: [PATCH] fix: fixed size change --- .../graphic-walker/src/vis/react-vega.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/graphic-walker/src/vis/react-vega.tsx b/packages/graphic-walker/src/vis/react-vega.tsx index 6a1a1adf..120aa902 100644 --- a/packages/graphic-walker/src/vis/react-vega.tsx +++ b/packages/graphic-walker/src/vis/react-vega.tsx @@ -228,8 +228,26 @@ const ReactVega = forwardRef(function ReactVe const renderTaskRefs = useRef[]>([]); const { width: areaWidth, height: areaHeight, ref: areaRef } = useResizeDetector(); - const vegaWidth = layoutMode === 'auto' ? 0 : areaWidth || width; - const vegaHeight = layoutMode === 'auto' ? 0 : areaHeight || height; + const getSize = () => { + if (layoutMode === 'auto') { + return { + width: 0, + height: 0, + }; + } + if (layoutMode === 'full' && areaWidth && areaHeight) { + return { + width: areaWidth, + height: areaHeight, + }; + } + return { + width, + height, + }; + }; + + const { width: vegaWidth, height: vegaHeight } = getSize(); const specs = useMemo( () =>