JS file invocation in Jupyter Notebook and data sharing

I am interested in placing javascript-enabled graphics in my jupyter laptop file as a div. This website uses a code magic approach and inserts the graph code directly into the jupyter laptop cell:

http://blog.thedataincubator.com/2015/08/embedding-d3-in-an-ipython-notebook/

However, since many of these javascript-enabled graphs are long, I think it would be easy to just call a javascript file containing the graph code, and then add it as a div in the jupyter notebook. It sounds simple enough, but with the whole crossroads of the road, I was confused by myself, and I’m not sure which approaches I tried work or not.

I tried:

%%javascript require.config({ paths: { graph: 'filepath.js' } }); 

This did not cause any errors, but when I could not add any divs. I think maybe the problem is how the data is connected between python and js file. The link above uses an approach that points to window.vizObj={} I wonder if there are any simpler solutions?

In addition, there is a converter library: http://mpld3.imtqy.com/ . Of course, I am not against this, but for the sake of illustration (and pride) I would like to understand this. Please feel free to share any thoughts on this.

If possible, download the jupyter laptop file so that I can see how one of them adds the js-chart to the jupyter-notepad from the js file and how the data is indicated. Any type of graph is fine, maybe a simple graph d3.js.

+7
jupyter-notebook
source share

No one has answered this question yet.

See related questions:

29th
Python & Matplotlib: Make 3D Graphics Interactive in Jupyter Notebook
8
How to create modules in a Jupyter laptop and import them? python
3
Failed to connect to Jupyter laptop served by Docker
3
Conda / Python: Import error - image not found only in jupyter laptop
3
How can I get the python path changed for all ipython laptops that run from this jupyter laptop instance?
2
Messages and laptops Jupyter
one
Notebook jupyter source folder will not change
one
IPython / Jupyter laptops after the obsolete GoogleDrive host,
0
How to edit text pack in jupyter laptops?

All Articles