D3.js Download version 3 vs version 4 in a Jupyter Notebook

If I try to download the d3.js library to my jupyter laptop, it works fine with version 3.x. Then I can go to the chrome console and the d3 object is available.

from IPython.core.display import display, HTML HTML('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>') 

If I do the same with version 4.x , it is not available, even if it appears on the Chrome tool’s sources tab.

 from IPython.core.display import display, HTML HTML('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>') 

What am I doing wrong?

+5
source share
1 answer

Got the answer from the link mentioned in the comment, but actually I had to leave .js at the end of the d3 path, because requirejs added it automatically, and so it tried to call https://d3js.org/d3.v4.js.js which returns 404.

Code that worked for me in jupyter:

 from IPython.core.display import display, HTML HTML(''' <script> requirejs.config({ paths: { d3: 'https://d3js.org/d3.v4' } }); require(['d3'], function(d3) { window.d3 = d3; }); </script> ''') 
+1
source

Source: https://habr.com/ru/post/1270919/


All Articles