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
评论列表
文章目录