【发布时间】:2020-07-25 05:38:30
【问题描述】:
我正在尝试将 HoverTool 链接到散景中的切换按钮。我想生成一个独立的仪表板作为 html,所以我想使用一些自定义 javascript 来使用切换按钮切换悬停工具。
这里是一些示例代码:
from bokeh.plotting import ColumnDataSource, figure, output_file, show
from bokeh.layouts import row
from bokeh.models import Toggle, CustomJS
output_file("toolbar.html")
source = ColumnDataSource(
data=dict(x=[1, 2, 3, 4, 5], y=[2, 5, 8, 2, 7], desc=["A", "b", "C", "d", "E"],)
)
TOOLTIPS = [
("index", "$index"),
("(x,y)", "($x, $y)"),
("desc", "@desc"),
]
p = figure(
plot_width=400, plot_height=400, tooltips=TOOLTIPS, title="Mouse over the dots"
)
p.circle("x", "y", size=20, source=source)
# I would like to have some js code activate and deactivate the Hovertool
# and delete the option for the hovertool from the plots sidebar
button = Toggle(label="HoverTool", button_type="success")
show(row(p, button))
【问题讨论】:
标签: javascript python bokeh interactive