mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2025-12-21 21:22:25 +00:00
feat: add StorageManager, VisualizationManager, UIManager, EditorManager, and update PanelResizer for improved snippet handling and visualization
This commit is contained in:
22
src/VisualizationManager.js
Normal file
22
src/VisualizationManager.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export class VisualizationManager {
|
||||
constructor(containerId = 'vis') {
|
||||
this.containerId = containerId;
|
||||
}
|
||||
|
||||
async updateVisualization(spec) {
|
||||
try {
|
||||
const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
|
||||
parsedSpec.width = parsedSpec.width || 'container';
|
||||
parsedSpec.height = parsedSpec.height || 'container';
|
||||
|
||||
await vegaEmbed(`#${this.containerId}`, parsedSpec, {
|
||||
actions: true,
|
||||
theme: 'light'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error rendering visualization:', err);
|
||||
document.getElementById(this.containerId).innerHTML =
|
||||
`<div style="color: red; padding: 1rem;">Error rendering visualization: ${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user