将javascript加载到ipython notebook中

时间:2014-08-21 04:01:11

标签: ipython-notebook dc.js crossfilter

我正在尝试导入以下三个js库。他们都工作,除了crossfilter.js。谁能告诉我我做错了什么?

import jinja2
from IPython.display import display, Javascript, HTML

%%javascript
require.config({
    paths: {
        d3: '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.min',
        crossfilter: '//cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.7/crossfilter.min',
        dc: '//cdnjs.cloudflare.com/ajax/libs/dc/1.7.0/dc.min'
    }
});

dc = jinja2.Template(
"""

require(["d3","crossfilter","dc"], function(d3,crossfilter,dc) {    

    console.log(d3);
    console.log(crossfilter);
    console.log(dc);    

});    
""")

display(Javascript(dc.render()))

我得到的输出:

对象
未定义
对象

1 个答案:

答案 0 :(得分:1)

Crossfilter(尚未)支持requireJS:

https://github.com/square/crossfilter/issues/114

该故障单显示了如何使用填充配置加载它。