from IPython.core.display import HTML
#HTML('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script>')
#HTML('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.0.0/d3.js"></script>')from IPython.core.display import HTML
HTML('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.0.0/d3.js"></script>')
HTML("<script>alert(d3)</script>")
You should get an alert box that says [object Object], since d3 is an object, but you don't. It works fine with the older version of D3, just change the 4.0.0 to 3.5.17.
The same problem happens with MathJS. As a result, I ended up writing my own little complex class for this example including polynomial evaluation with Horner's method. Not that big deal for this example, but MathJS includes a lot of functionality that might be nice to incorporate for these types of examples. It also includes a parser that would make it very easy to translate mathematical expressions from Python to Javascript.Sorry for the silence!
d3 v4 must be loaded with require, e.g.
require(['d3'], function (d3) {
d3.....
})
So each output should have a require call like this.
You can tell require where to get d3 with:
require.config({
paths: {
d3: "https://d3js.org/d3.v4.min"
}
});
which you will need to do one time, before require('d3') will work.
-Min