Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: fix: make altair and vega work in colab #292

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions solara/widgets/vue/vegalite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ module.exports = {
});
},
async loadVega() {
// we need to remove the define function to avoid conflicts with requirejs
// which will do an early exit:
// https://github.com/requirejs/requirejs/blob/898ff9e60eb6897500720151c0b488b8749fbe8d/require.js#L177
// the define function is added by on colab when widgets are loaded:
// https://github.com/googlecolab/colab-cdn-widget-manager/blob/664b13da3289597966bfb5b7dd5e347233d48524/src/amd.ts#L81
const previousDefine = window.define;
delete window.define;
await this.loadRequire();
requirejs.undef("vega")
requirejs.undef("vega-lite")
Expand All @@ -70,6 +77,8 @@ module.exports = {
// pre load
await new Promise((resolve, reject) => {
require(['vega', 'vega-lite', 'vega-embed'], () => {
// should we restore the define function?
window.define = previousDefine;
resolve()
}, reject)
});
Expand Down
Loading