score:0

Maybe you want to access a local javascript file by url in the jupyter notebook?

I found the '/files' path is a good workaround, use:

require.config({
  paths: {
      d3: '/files/js/d3.min'
  }
});

if you save the local file under the 'js' directory of the root of the jupyter server.

score:1

Once downloaded locally, you can do:

%%javascript

element.append('<div id="viz"></div>');

require(['d3.min.js'], function(d3){

var sampleSVG = d3.select("#viz")
        .append("svg")
        .attr("width", 100)
        .attr("height", 100);    

sampleSVG.append("circle")
        .style("stroke", "gray")
        .style("fill", "white")
        .attr("r", 40)
        .attr("cx", 50)
        .attr("cy", 50)
        .on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
        .on("mouseout", function(){d3.select(this).style("fill", "white");});  

});

Related Query

More Query from same tag