如何从点击事件hvnx.draw获取选定的索引?

时间:2019-06-25 06:04:40

标签: python python-3.x bokeh

我已经能够快速显示networkx图而没有问题。 但是,我无法在tap event上检索选定的索引?

from bokeh.models import HoverTool, TapTool, CustomJS
from bokeh.io import show

callback = CustomJS( code="""
// the event that triggered the callback is cb_obj:
// The event type determines the relevant attributes
console.log('Tap event occurred')
console.log(arguments)
// console.log(cb_obj)
console.log(cb_data.source.data)
""")

GG = nx.Graph()
GG.add_edge('A','B')
GG.add_edge('B','C')
GG.add_edge('C','A')
hvnx.draw(GG).opts(tools=[TapTool(callback=callback), HoverTool(tooltips=[('index', '@index_hover')])])

# HOW-TO get node-id in JS callback?
# sx: 67.2230224609375
# sy: 45.66761779785156
# type: "point"
# x: -0.4242418711022395
# y: 0.8824665128664352

# index_hover: Array(3)
# 0: "A"
# 1: "B"
# 2: "C"

0 个答案:

没有答案