Как получить выбранный индекс из события hvnx.draw? - PullRequest
0 голосов
/ 25 июня 2019

Я смог быстро отобразить график сети x без проблем.Однако мне не удалось получить выбранный индекс для 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"

...