tkf / emacs-ipython-notebook

IPython notebook client in Emacs
tkf.github.com/emacs-ipython-notebook/
GNU General Public License v3.0
548 stars 51 forks source link

Vega support #182

Open jpivarski opened 7 years ago

jpivarski commented 7 years ago

This is wonderful, except... I can't view Vega objects (https://github.com/vega/ipyvega/blob/master/notebooks/Vega.ipynb) because of

ein: [info] ein:cell-append-mime-type does not support dynamic
javascript. got: var spec = {
   ...
};
var selector = "#d6680810-6e10-4ed2-9ddc-8b96569367bb";
var type = "vega";

var output_area = this;
require(['nbextensions/jupyter-vega/index'], function(vega) {
  vega.render(selector, spec, type, output_area);
}, function (err) {
  if (err.requireType !== 'scripterror') {
    throw(err);
  }
});

Is there any hope that a future version will be able to deal with this? If so, when?

millejoh commented 7 years ago

Slim hope, but hope. I have an experimental branch at https://github.com/millejoh/emacs-ipython-notebook/tree/dynamic-javascript that has very basic support for running javascript using skewer. The problem, as I understand it, is that vega works by updating the DOM of the webpage it is running in - something that does not make much sense in an Emacs buffer.

My initial thought is that this might work if I can get Vega to run in headless mode and run a jpeg/svg image - something EIN knows how to handle very well.

Wish me luck. I don't get a lot of time to work on this project but agree it would be very cool feature to have.

jpivarski commented 7 years ago

Do you suppose you could call out to nodejs? The Vega npm package has two executables, vg2png and vg2svg that can go through standard in/out. The PNG conversion uses the npm Canvas package, which requires a lot of compiled Cairo libraries, but SVG is just DOM manipulation. I think Canvas is a formal dependency for the Vega npm package, though.

millejoh commented 7 years ago

This is an interesting idea - wrap this in Python and the notebook will do "the right thing" as far as letting EIN know there is a image on the way. Again, work goes slowly at times but I will try to look more into doing this.

Thanks for the suggestion!