mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
Merge pull request #18040 from rgaricano/dev-FEAT_Vega_Visualizer
FEAT: Add Vega-Lite Char Visualizer Renderer
This commit is contained in:
commit
f65231becb
2 changed files with 9 additions and 1 deletions
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue