Skip to content

Commit 036b4b2

Browse files
committed
feat: add responsive sizing to VegaEmbed component
Configure vega-embed with autosize fit-x to make visualizations responsive to container width while maintaining aspect ratio. This prevents overflow and reduces excessive whitespace.
1 parent ae8b0c4 commit 036b4b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/components/common/VegaEmbed/vegaEmbed.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ export const VegaEmbed = ({ caption, spec }: VegaEmbedProps): JSX.Element => {
3939
vegaSpec = spec;
4040
}
4141

42-
// Embed the visualization
42+
// Embed the visualization with responsive sizing
4343
await embed(containerRef.current, vegaSpec, {
4444
actions: {
4545
compiled: false,
4646
editor: false,
4747
export: true,
4848
source: false,
4949
},
50+
config: {
51+
autosize: {
52+
contains: "padding",
53+
type: "fit-x",
54+
},
55+
},
5056
});
5157
setError(null);
5258
} catch (err) {

0 commit comments

Comments
 (0)