0

In an HTML script, a call to fetch a package ending in vega@n where n is a version number, is being incorrectly expanded and causing a 404 error. I'm trying to find out why, and to prevent this.

Apologies in advance for the long-winded explanation, but I'm not sure where the problem lies so I'm trying to be as specific as possible.

I'm following the user guide to try and load a vis into a jupyter notebook. This executes the script in-browser, I believe, but for some reason has support for requireJS, which means that global modules aren't correctly loaded when using the import method, which basically uses html's <script> tags to load the module.

This can be worked around by calling define, as described in a similar problem with D3, here: https://github.com/mpld3/mpld3/issues/33#issuecomment-32101013.

I've written this gist to show a working example:

https://gist.github.com/lJoublanc/439e2f687b7aedd6fbdea5adab5cee0f

However, for some reason (either requireJS or something else - my JS knowledge is limited), expands URLs of the form https://cdn.jsdelivr.net/npm/vega@3 into something like https://cdn.jsdelivr.net/npm/vega@3.js?v=20180324103700 which results in a 404 error.

Using the github URL (i.e. without the @3) works fine though.

Any idea if this is requireJS doing this, or the CDN? How would I work around it?

Luciano
  • 2,388
  • 1
  • 22
  • 33
  • I know this doesn't answer your original question but you can use https://github.com/vega/ipyvega to use Vega in Jupyter notebooks. – dominik Apr 29 '18 at 17:19
  • @dominik I'm afraid I'm using a **scala** language kernel, so this won't work. However I'll have a look at how it's implemented in ipyvega to see if I can replicate that. – Luciano Apr 30 '18 at 07:17
  • Hmm, that expansion seems odd. Can you use https://cdn.jsdelivr.net/npm/vega@3/build/vega.min.js instead? – dominik Jun 04 '18 at 16:54

0 Answers0