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

Support for bokeh (Python) or Gadfly (Julia)? #65

Closed
kietdlam opened this issue Jul 12, 2015 · 7 comments
Closed

Support for bokeh (Python) or Gadfly (Julia)? #65

kietdlam opened this issue Jul 12, 2015 · 7 comments

Comments

@kietdlam
Copy link

I was wondering what the support for interactive plotting like bokeh in Python or Gadfly in Julia would look like? This would be really interesting for interactive plotting.

@millejoh
Copy link
Owner

Bokeh relies on the execution of javascript in the web browser - something that Emacs is not capable of, to my knowledge. That also means that widgets will probably never work in EIN. A possible solution/workaround might be to have ein open a web page in these cases..

@CestDiego
Copy link
Contributor

unless the xwidgets branch ever gets merged http://labs.it-huset.se/jenkins/job/Emacs/

@jlstevens
Copy link

I would also be very interested in working with bokeh from EIN and, more generally, visualizations that need to execute in Javascript in a browser.

As I understand it, the latest emacs versions do support xwidgets, if you compile it appropriately. Unfortunately, I've not found an OSX build that is xwidgets enabled and I expect the build process to be quite painful (I expect it would be quited easy on linux!).

Another approach is discussed in the original EIN repo here. In short, the idea is to use skewer-mode which seems like a more maintainable/sensible approach to me. In fact, this is something @millejoh already prototyped in this repo on this this branch.

What is the status of that prototype? If it was promising and just needs a bit more work, I might be able contribute - I am using notebooks constantly (which need web rendering) and working with code outside emacs is becoming intolerable!

@millejoh
Copy link
Owner

Using skewer-mode did actually work, in that one could execute arbitrary Javascript expressions and getting output into the notebook. The problem comes when the Javascript tries to manipulate/access the DOM, which I believe is what happens with IPython widgets and many notebook extensions. Getting a bokeh interactive graph embedded in an EIN notebook is not something that I see as possible at this point.

My one hope is that with skewer-mode the javascript runs in the browser, so if one is clever in outputting the right HTML to, say, simulate an ipython output cell before running any javascript then at least one could get the bokeh graph running in a browser tab.

@jlstevens I am always happy to have contributions! If you have any questions on the code don't hesitate to ask.

@jlstevens
Copy link

I asked a core bokeh dev about DOM manipulation and bokeh only manipulates things under one div which it creates as part of the HTML output. I don't know enough about skewer mode just yet but why would DOM manipulation be an issue once the HTML/JS has been sent to the browser?

@jlstevens
Copy link

Getting a bokeh interactive graph embedded in an EIN notebook is not something that I see as possible at this point.

I now realize you meant getting it to display within emacs. As lovely as that would be, I agree this isn't going to be possible any time soon.

My one hope is that with skewer-mode the javascript runs in the browser, so if one is clever in outputting the right HTML to, say, simulate an ipython output cell before running any javascript then at least one could get the bokeh graph running in a browser tab.

That would be the idea! I have finally had a chance to play around with this. I did manage to get a bokeh plot to update via skewer mode.

First I had to make sure all Javascript was referenced as .js files in script tags - any inline scripting messed up skewers ability to evaluate HTML. This meant that the body (ignoring the scripts in the header) looked like:

<body>
  <div style='display: table; margin: 0 auto;'>

    <div class="bk-root">
        <div class="bk-plotdiv" id="1adf03d2-0c1d-4469-9287-8632d6417a00"></div>
    </div>
    <script src="http://localhost:8000/plot.js"></script>
  </div>
</body>

where plot.js contains the JS associated with that bokeh plot, including the JSON representation bokeh uses to specify the plot data.

Then I could update the plot by fiddling with the JSON values in plot.js from emacs in two steps:

  • C-M-x (skewer-html-eval-tag) with the point on the div with the id.
  • C-c C-k (skewer-load-buffer) in plot.js.

Everything continued to work if I replaced the id "1adf03d2-0c1d-4469-9287-8632d6417a00" with
"11111111-2222-3333-4444-555555555555", as long as I did it both in the HTML and in plot.js.

More importantly, I was able to generate an entirely different type of bokeh plot and update to it, by completely replacing plot.js with new javascript, making sure to replace the corresponding id with "11111111-2222-3333-4444-555555555555".

It looks to me like there could be a path forward, serving the appropriate plot.js that needs to be displayed and some fixed HTML template in which the plot can live. I would like to play with this more but first I should learn more about the existing attempt to get skewer mode and EIN working together.

For instance, how would running a cell that would output a bokeh plot (in the normal notebook environment) update the plot shown in the browser via skewer? Would there be a shortcut for the user to hit or does EIN have the equivalent of display hooks that could do this automatically?

dickmao added a commit that referenced this issue Feb 1, 2020
@dickmao
Copy link
Collaborator

dickmao commented Feb 1, 2020

ein-skewer is no longer available.

EIN has no plans to support widgets until webkit integrates with emacs (unlikely to happen in the medium term).

@dickmao dickmao closed this as completed Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants