py_d3.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:py_d3 作者: ResidentMario 项目源码 文件源码
def d3(self, line, cell):
        src = line if len(line) > 0 else "3.5.17"
        s = """
<script>
requirejs.config({
    paths: {
        d3: "//cdnjs.cloudflare.com/ajax/libs/d3/""" + src + """/d3"
    }
});

require(['d3'], function(d3) {
    window.d3 = d3;
});
</script>
<script>
_select = d3.select;

d3.select""" + str(self.max_id) + """ = function(selection) {
    return _select("#d3-cell-""" + str(self.max_id) + """").select(selection);
}
d3.selectAll""" + str(self.max_id) + """ = function(selection) {
    return _select("#d3-cell-""" + str(self.max_id) + """").selectAll(selection);
}
</script>
<g id="d3-cell-""" + str(self.max_id) + """">
"""
        cell = re.sub('d3.select\((?!this)', "d3.select" + str(self.max_id) + "(", cell)
        cell = re.sub('d3.selectAll\((?!this)', "d3.selectAll" + str(self.max_id) + "(", cell)
        s += cell + "\n</g>"
        # print(s)  # Useful for debugging.
        h = HTML(s)
        self.max_id += 1
        display(h)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号