[IPython-User] [IPython-dev] "Freezing" dynamic content with nbconvert, was ANN: Exhibitionist
Tue Mar 19 17:38:34 CDT 2013
I really like this idea. And libs like d3 make it easy - it already
produces svg and the notebook already knows how to store svg output in
the JSON data. I think the usage of iframes is not needed in general
for this to work though, but I can see how you need it for now...
We will keep this in our minds as we start to work on the interactive
widgets later this year.
On Tue, Mar 19, 2013 at 11:06 AM, yoval p. <firstname.lastname@example.org> wrote:
> I've been looking for a way to showcase (and dogfood) the
> library I released a couple of weeks ago, Exhibitionist
> Yesterday, I started work enhancing the wonderful notebooks on
> MCMC released by @CamDavidsonPilon at:
> with interactive views of various kinds.
> I wanted to share a pleasent success I had in "freezing" a dynamic
> based on d3 and data streaming via AJAX, into a static view which is stored
> the notebook, and viewable in nbviewer.
> Here's a screenshot:
> the upper view is dyanmic, and you can control the lambda parameter of the
> exponential distribution plotted in realtime.
> The lower view is the result of hitting the "freeze" button in the upper
> right corner,
> and is saved with the notebook, viewable even without exhibitionist
> - completely reproducable.
> A nice feature of this, is that you can interactively "tweak" your plot
> until you're satisfied, and then freeze the plot for "publication".
> I plan to working on gradually enhancing all the book chapters in this way,
> and release the notebooks on github.
> If anyone has a need to do something similar, here are the technical bullet
> points for how this works:
> - the dynamic view lives in an embedded iframe
> - the HTML5 postmessage API is used for exchanging messages between
> the iframe and the IPPython main window.
> - when the "freeze" button is clicked, the svg blob generated by d3 (using
> json data fetched over AJAX, from an exhibitioinst server running n the
> kernel process) is sent over to the IPython window.
> - the listener catching the message introspects the cells using the IPython
> js object, and jquery to replace the IFrame with the svg blob, and to
> the cell output area so that the svg data is serialized when the notebook
> is saved.
> - Styiing the svg is an interesting problem. You can include the css ctyles
> for the plot in the IPython notebook, or, if you inline the styles as svg
> attributes, the plot becomes completely self-contained. I'm using the latter
> for now.
> This was really excited to get working, I wasn't even sure it's possible. It
> ----- Original Message -----
> From: Matthias BUSSONNIER
> Sent: 03/07/13 07:39 PM
> To: IPython developers list
> Subject: Re: [IPython-dev] "Freezing" dynamic content with nbconvert, was
> ANN: Exhibitionist
> Hi Yoval,
> Le 7 mars 2013 à 17:48, yoval p. a écrit :
> My suggestion is that the display protocol be modified so that the
> semantics of
> `_repr_html_` would mean static HTML only, and a new `_repr_jshtml_`
> (however named)
> magic method would be supported, under which objects would implement
> dynamic views.
> What you describe look IMHO to much to the current
> and something in those line was my first idea, but dealing with displaying
> We are also certain that we can have a more general approach.
> (Keep in mind that, thinking of the display protocol as only html/js
> notebook/qtconsole is also much too restrictive)
> In short, we believe using _display_json_ is the right way and is enough.
> Most of the time, when you display js, the only thing you want to send are
> data that need to be interpreted.
> to display generated code.
> This allow also to depend on other installed plugin without having to embed
> lib like jQuery etc at every call.
> In framework like chromium embeded, you cannot in any way execute code that
> are in script tag. The js
> **have to** be part of the application at launch time.
> totally possible as simple small plugin
> it will just not be supported.
> As for nbviewer, if there is a _repr_json_ , nothing prevent it from using
> it in html to have dynamic represent,
> but the same json could be use to make a Tikz representation in latex, or
> even multiple plugin could be able to interpret the same json.
> So after long repletion, I am convince that json-repr is the way to go.
> We'll still consider the suggestion of course, and discussion are welcomed.
> IPython-dev mailing list
> IPython-User mailing list
Brian E. Granger
Cal Poly State University, San Luis Obispo
email@example.com and firstname.lastname@example.org
More information about the IPython-User