Skip to content

Commit

Permalink
fix: fixed size change
Browse files Browse the repository at this point in the history
  • Loading branch information
islxyqwe committed Aug 28, 2024
1 parent 436e7bf commit d1b017c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/graphic-walker/src/vis/react-vega.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,26 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
const renderTaskRefs = useRef<Promise<unknown>[]>([]);
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(
() =>
Expand Down

0 comments on commit d1b017c

Please sign in to comment.