graph.py 文件源码

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

项目:snowballing 作者: JoaoFelipe 项目源码 文件源码
def display(self, *args):
        """Display interactive graph"""
        if self._display_stack:
            if not self.delayed:
                self._display_stack -= 1
            if self._display_stack:
                # Skip display if other widgets will invoke display soon
                return False
        self.output_widget.clear_output()
        with self.output_widget:
            work_list, references = self.graph()
            display(self._svg_name)
            svg = SVG(self._svg_name)
            svg._data = svg._data[:4] + ' class="refgraph"' + svg._data[4:]
            display(svg)

            interaction = """
                $(".hoverable polyline, .hoverable line").mouseenter(
                    function(e) {
                        //e.stopPropagation();
                        $(this).css("stroke", "blue");
                        $(this).css("stroke-width", "3px");
                    }).mouseleave(
                    function() {
                        $(this).css("stroke", "black");
                        $(this).css("stroke-width", "inherit");
                    });
            """
            display(Javascript(interaction))
            display(HTML("""
                <script type="text/javascript">
                    %s

                    require(["./svg-pan-zoom"], function(svgPanZoom) {
                        svgPanZoom('.refgraph', {'minZoom': 0.1});
                    });
                </script>
            """ % (
                open(
                    Path(__file__) / ".." / ".." /
                    "resources" / "svg-pan-zoom.min.js"
                ).read(),
            )))

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号