[IPython-dev] Seeing javascript visualization from nbviewer?

Brian Granger ellisonbg at gmail.com
Fri Mar 14 11:32:37 EDT 2014

If the library is aware of require.js, you should use that. But the
calling syntax for require is similar to `getScript` is similar - the
second argument is a function that gets called when the libraries are
loaded. These days, many JavaScript libraries have to be loaded with
require.js in the notebook. With IPython 2.0, all different ways
should work fine on nbviewer/nbconvert though.

On Fri, Mar 14, 2014 at 5:45 AM, Doug Blank <doug.blank at gmail.com> wrote:
> I think the problem was with my implementation of Javascript(..,
> lib=...). I see that the lib is used like this in the Python kernel:
> $.getScript("https://www.google.com/jsapi", function () {
>    [code]
> }
> whereas I had:
> require["https://www.google.com/jsapi"];
> [code];
> Which did work, but only when running the cells.
> Is putting Javascript(lib="") the best method for including external
> Javascript libraries that are used often/many times? Or is there
> something I should add to custom.js that would load it at the right
> time?
> -Doug
> On Fri, Mar 14, 2014 at 2:01 AM, Doug Blank <doug.blank at gmail.com> wrote:
>> I am working on migrating a Google visualization example [1] by
>> victor_zverovich to a simpler version shown here:
>> http://nbviewer.ipython.org/urls/bitbucket.org/ipre/calico/raw/master/notebooks/GeoChart.ipynb
>> (users using the regular IPython Python kernel can just change
>> calico.Javascript to Javascript and import it from IPython.display)
>> What do I need to do be able to have the GeoChart render in nbviewer?
>> Is that possible? Currently I get the same error I get before I
>> execute the cells when I first open the notebook:
>> """
>> Javascript error adding output!
>> ReferenceError: google is not defined
>> """
>> Any insight appreciated!
>> -Doug
>> [1] - http://zverovich.net/2013/06/27/visualizing-geographical-ampl-data-using-ipython-and-google-charts.html
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com

More information about the IPython-dev mailing list