Bokeh 服务器 - 使用点击工具更改 select 上的字形颜色
Bokeh Server - Change color of glyph on select with Tap Tool
我想将 TapTool 与 Bokeh 服务器一起使用,以 运行 具有一些附加功能的回调。
我想要 select 的字形位于背景图片之上。
如果我 select 使用 TapTool 的字形,字形会保持其不透明度,但所有其他字形的不透明度都会降低。问题是当这些字形变得更加不透明时,它们在背景图像上就看不清楚了。
有没有办法将字形的 alpha 值全部保留为 100%,而不是更改 selected 字形的颜色?
这是我找到的一些示例代码作为开始 here
from bokeh import plotting as bplt
from bokeh import layouts as blayouts
from bokeh import models as bmodels
from bokeh import io as bio
fig = bplt.figure(tools="tap")
source = bmodels.ColumnDataSource(dict(x=[0,1], y=[0,1]))
r = fig.circle('x', 'y', source=source, size=10)
def handler(attr, old, new):
print('attr: {} old: {} new: {}'.format(attr, old, new))
# r.data_source.on_change('selected', handler)
r.data_source.selected.on_change('indices', handler)
bio.curdoc().add_root(blayouts.layout([[fig]]))
这是散景 2.0.1 的工作示例:
from bokeh import plotting as bplt
from bokeh import layouts as blayouts
from bokeh import models as bmodels
from bokeh import io as bio
fig = bplt.figure(tools="tap")
source = bmodels.ColumnDataSource(dict(x=[0,1], y=[0,1]))
r = fig.circle('x', 'y', source=source, size=10, color='#000000',
# set visual properties for selected glyphs
selection_color="#2bff00",
# set visual properties for non-selected glyphs
nonselection_fill_alpha=1.0,
nonselection_fill_color="#000000")
def handler(attr, old, new):
print('attr: {} old: {} new: {}'.format(attr, old, new))
# r.data_source.on_change('selected', handler)
r.data_source.selected.on_change('indices', handler)
bio.curdoc().add_root(blayouts.layout([[fig]]))
我想将 TapTool 与 Bokeh 服务器一起使用,以 运行 具有一些附加功能的回调。
我想要 select 的字形位于背景图片之上。
如果我 select 使用 TapTool 的字形,字形会保持其不透明度,但所有其他字形的不透明度都会降低。问题是当这些字形变得更加不透明时,它们在背景图像上就看不清楚了。
有没有办法将字形的 alpha 值全部保留为 100%,而不是更改 selected 字形的颜色?
这是我找到的一些示例代码作为开始 here
from bokeh import plotting as bplt
from bokeh import layouts as blayouts
from bokeh import models as bmodels
from bokeh import io as bio
fig = bplt.figure(tools="tap")
source = bmodels.ColumnDataSource(dict(x=[0,1], y=[0,1]))
r = fig.circle('x', 'y', source=source, size=10)
def handler(attr, old, new):
print('attr: {} old: {} new: {}'.format(attr, old, new))
# r.data_source.on_change('selected', handler)
r.data_source.selected.on_change('indices', handler)
bio.curdoc().add_root(blayouts.layout([[fig]]))
这是散景 2.0.1 的工作示例:
from bokeh import plotting as bplt
from bokeh import layouts as blayouts
from bokeh import models as bmodels
from bokeh import io as bio
fig = bplt.figure(tools="tap")
source = bmodels.ColumnDataSource(dict(x=[0,1], y=[0,1]))
r = fig.circle('x', 'y', source=source, size=10, color='#000000',
# set visual properties for selected glyphs
selection_color="#2bff00",
# set visual properties for non-selected glyphs
nonselection_fill_alpha=1.0,
nonselection_fill_color="#000000")
def handler(attr, old, new):
print('attr: {} old: {} new: {}'.format(attr, old, new))
# r.data_source.on_change('selected', handler)
r.data_source.selected.on_change('indices', handler)
bio.curdoc().add_root(blayouts.layout([[fig]]))