我看到了这个例子
from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.plotting import figure, output_file, show
output_file("openurl.html")
p = figure(plot_width=400, plot_height=400,
tools="tap", title="Click the Dots")
source = ColumnDataSource(data=dict(
x=[1, 2, 3, 4, 5],
y=[2, 5, 8, 2, 7],
color=["navy", "orange", "olive", "firebrick", "gold"]
))
p.circle('x', 'y', color='color', size=20, source=source)
# use the "color" column of the CDS to complete the URL
# e.g. if the glyph at index 10 is selected, then @color
# will be replaced with source.data['color'][10]
url = "http://www.colors.commutercreative.com/@color/"
taptool = p.select(type=TapTool)
taptool.callback = OpenURL(url=url)
show(p)
我想做类似的事情,而不是打开网址,当我点击与该圆圈相关的圆圈时,我想在右边显示一些文字 . 当我点击另一个圆圈时,文本应该会改变 .
我也看到了这个:https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/callbacks.html#customjs-for-user-interaction-events但我无法根据圆圈改变一些文字的鼠标打印 .
谢谢 .
1 回答
使用
CustomJS
而不是OpenUrl
更多解释见这里JavaScript callback to get selected glyph index in Bokeh