[IPython-dev] _repr_javascript_ code samples for D3
Stefan Krastanov
krastanov.stefan at gmail.com
Tue May 14 09:36:17 EDT 2013
I was able to hack together something that uses `publish_html` and
`publish_javascript` in order to create a D3 graphic from within the
ipython notebook:
Prepare a container:
publish_html("""
<div id="sympy_d3_plot_%d"></div
"""%_ipython_div_counter)
Load the library
publish_javascript("""
var script = document.createElement("script");
script.src = "http://d3js.org/d3.v3.min.js";
document.body.appendChild(script);
""")
And after that another `publish_javascript` for doing the D3.js specific stuff.
However I do not believe this is the correct way to create objects
that visualize nicely in IPython. Is there a guide how to do this The
Right Way(TM)?
On 8 May 2013 11:02, Stefan Krastanov <krastanov.stefan at gmail.com> wrote:
> Hi all,
>
> I have seen a nice visualization of networkx graph through d3.js in
> the notebook. I want to use D3 to visualize some other objects. I
> guess I should use `_repr_javascript_` but I do not know how the
> scoping of javascript libraries works, how much is sandboxed by the
> notebook, where to include the library, etc. I was hoping that you can
> point me to a code sample that does it The Right Way(TM).
>
> A quick code search on github did not return anything useful.
>
> Regards
> Stefan
More information about the IPython-dev
mailing list