Merge pull request #18040 from rgaricano/dev-FEAT_Vega_Visualizer

FEAT: Add Vega-Lite Char Visualizer Renderer
This commit is contained in:
Tim Jaeryang Baek 2025-10-03 23:52:30 -05:00 committed by GitHub
commit f65231becb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -138,6 +138,7 @@
"undici": "^7.3.0", "undici": "^7.3.0",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"vega": "^6.2.0", "vega": "^6.2.0",
"vega-lite": "^6.4.1",
"vite-plugin-static-copy": "^2.2.0", "vite-plugin-static-copy": "^2.2.0",
"y-prosemirror": "^1.3.7", "y-prosemirror": "^1.3.7",
"yaml": "^2.7.1", "yaml": "^2.7.1",

View file

@ -1601,7 +1601,14 @@ export const renderVegaVisualization = async (spec: string) => {
try { try {
const vega = await import('vega'); const vega = await import('vega');
const parsedSpec = JSON.parse(spec); const parsedSpec = JSON.parse(spec);
const view = new vega.View(vega.parse(parsedSpec), { renderer: 'none' }); let vegaSpec;
if (parsedSpec.$schema && parsedSpec.$schema.includes('vega-lite')) {
const vegaLite = await import('vega-lite');
vegaSpec = vegaLite.compile(parsedSpec).spec;
} else {
vegaSpec = parsedSpec;
}
const view = new vega.View(vega.parse(vegaSpec), {renderer: 'none'});
const svg = await view.toSVG(); const svg = await view.toSVG();
return svg; return svg;
} catch (error) { } catch (error) {