emacs-jupyter/jupyter

Support javascript output

Open

#53 opened on Mar 7, 2019

 (16 comments) (1 reaction) (0 assignees)Emacs Lisp (106 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (1,028 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I'm trying to use hvega which outputs vega-lite plots. The output is a javascript block. However, when running the source block I get no output and a warning: Warning (emacs): No valid mimetype found (:application/javascript). This is when trying the barcode example in https://raw.githubusercontent.com/DougBurke/hvega/master/notebooks/VegaLiteGallery.ipynb Obviously the interactivity isn't needed, but having it at least print out the javascript string would be beneficial on export. Best case scenario would be to have :file automatically export to .svg and .png.

MESSAGE: (:iopub :display-data (:data (:application/javascript requirejs({paths:{vg:’https://cdn.jsdelivr.net/npm/vega@3.2.1/build/vega.min’,vl:’https://cdn.jsdelivr.net/npm/vega-lite@2.3.0/build/vega-lite.min’,vge:’https://cdn.jsdelivr.net/npm/vega-embed@3.5.2/build/vega-embed.min’},shim:{vge:{deps:[’vg.global’,’vl.global’]},vl:{deps:[’vg’]}}});define(’vg.global’,[’vg’],function(g){window.vega = g;});define(’vl.global’,[’vl’],function(g){window.vl = g;});var ndiv = document.createElement(’div’);ndiv.innerHTML = ’Awesome Vega-Lite visualization to appear here’;element[0].appendChild(ndiv);require([’vge’],function(vegaEmbed){vegaEmbed(ndiv,{"mark":"bar","data":{"values":[{"a":"A","b":28},{"a":"B","b":55},{"a":"C","b":43},{"a":"D","b":91},{"a":"E","b":81},{"a":"F","b":53},{"a":"G","b":19},{"a":"H","b":87},{"a":"I","b":52}]},"$schema":"https://vega.github.io/schema/vega-lite/v2.json","encoding":{"x":{"field":"a","type":"ordinal"},"y":{"field":"b","type":"quantitative"}},"description":"A simple bar chart with embedded data."}).then(function (result) { console.log(result); }).catch(function (error) { ndiv.innerHTML = ’There was an error: ’ + error; });});) :metadata nil))

Contributor guide